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 (562)
 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
 
what is the difference between <stdio.h>and "stdio.h"?   5
explain dynamic binding by drowing Cognizent 2
create a c++ program that will accepts 9 inputs using 3 by 3 array.   1
Write 7 differences between "Public" function and "Private" function? IBM 2
sir i want to know which posting to apply since i am BE CSE.. also want to know what are the rounds there for my interview...Expecting for ur valuable answer....   2
some one give d clear explanation for polymorphism   3
ambiguity regulation of multiple inheritance with example.   1
What do you mean by pure virtual functions?   8
What is difference between #define and const? emc2 3
Write a program in c++ to read two floating point numbers and find their sum and average.   2
Difference between realloc() and free? HP 7
i ahve v low % in 12th n BSC which is aroun 50 coz science was imposed on me......nw m doin MCA n my aggregate in above 74%,what shud i say if asked about low previous percentage??????   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