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 (91)
 OOPS interview questions  OOPS Interview Questions (558)
 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 :: OOPS
I also faced this Question!!     Answer Posted By  
 
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
 
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 function overloading and operator overloading?   4
How to deploy web appliction in web logic ? Unisys 1
Why do we use virtual functions?   4
What are the valid types of data that the main () can return in C/C++ language   3
When is a memory allocated to a class?   11
3. Differentiate verification and validation.   1
difference between structure and union. Convergys 2
who is the founder of c++? Hexaware 15
What is virtual function?where and when is it used?   2
which are the 4 members functions in c++ objects that can either be declared explicitly by programmer or implementation if nt available.   4
What is friend function? Wipro 12
what is function overloading..?   4
 
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