ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C++ >> OOPS
 
 


 

 
 STL interview questions  STL Interview Questions (90)
 OOPS interview questions  OOPS Interview Questions (554)
 C++ General interview questions  C++ General Interview Questions (458)
Question
Round up a Decimal number in c++..

example Note = 3.5 is as 4
                 3.3 is as 3
 Question Submitted By :: Vivek
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3
Answer
# 1
#include <iostream>
#include <string>
using namespace std;


int main(void)
{
float a,b,c;
int k;
cout << "enter 1st number ";
cin>>a;
cout<<"enter 2nd number ";
cin>>b;
c=a/b;
cout<<"original value "<<c;
if (c=c+0.5)
{
k=c;
cout<<"\n"<<"round figure "<<k;
}
else
return 0;
}

Hope this code helped u smways
 
Is This Answer Correct ?    3 Yes 1 No
Vivek
 
  Re: Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3
Answer
# 2
void main()
{
float a,c;int b,d;
cout<<"ENTER ANY FLOAT VALUE:";
cin>>a;
b=a;c=(a-b);
if(c>=.5)
d=b+1;
else
d=b;
cout<<"AFTER ROUND UP THE DECIMAL NO IS:"<<d;
getch()
}
 
Is This Answer Correct ?    0 Yes 0 No
Vimala
 
 
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
what is the difference b/w abstract and interface? Merrill-Lynch 2
Why a "operator=(...)" when there is a copy ctor?   2
what is the difference between <stdio.h>and "stdio.h"?   5
What do we mean by a hidden argument in C++?   1
what is the use of template classes in c++   1
explain defference between structure and class with example   1
What is the difference between Home and $Home? TCS 2
polymorphism means? BFL 6
what are the disadvantages of C++? ATS 23
Difference ways of Polymorphism?   3
What is the default size allocated for array in the statement if size not specified " int a[] " CTS 4
what is a binary overloading   2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com