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 (459)
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
 
In the following declaration of main, "int main(int argc, char *argv[])", to what does argv[0] usually correspond? 1) The first argument passed into the program 2) The program name 3) You can't define main like that   6
Describe the difference between a Thread and a Process?   10
Program to check whether a word is in all capital letters   1
What do we mean by a hidden argument in C++?   1
write a c++ code to overload + and - for a stack class such that + provides push and - provides pop operation TCS 1
What is the difference between an object and a class?   3
When will a constructor executed? TCS 5
what is a binary overloading   2
What is Virtual Keyword? IBM 9
Explain the concept of abstracion and encapsulation with one example. What is the difference between them? PCS 3
What is a linked list? IBM 7
can you explain how to use JavaBean in Project Infosys 3
 
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