Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
 SiteMap shows list of All Categories in this site.

 Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS

 STL Interview Questions OOPS Interview Questions C++ General Interview Questions
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
# 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
# 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