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 (93)
 OOPS interview questions  OOPS Interview Questions (563)
 C++ General interview questions  C++ General Interview Questions (461)
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
 
There are 2 classes defined as below public class A { class B b; } public class B { class A a; } compiler gives error. How to fix it? Microsoft 3
what is runtime polymorphism? For the 5 marks.   3
how does a main() in C++ is different from main() in C?   6
why the memory allocated with new cant be freed using free()   2
143.what is oops principles?   10
What is design patterns in C++? Persistent 2
c++ provides classes...and classes do what we want but why then strcut are used...if we say data hiding... it is also provided by c++ in structs then why to prefer clasess TCS 1
How to create a comment page in C #??   2
Is following functions are said to be overloaded? int add(int a,int b) char *add(int a,int b)   4
what is costructor?   1
When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory?? Honeywell 13
what is a ststic variable and stiticfunction briefly explain with exmple and in which case we use HCL 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