Round up a Decimal number in c++..

example Note = 3.5 is as 4
3.3 is as 3

Answer Posted / vivek

#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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

1790


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1541


class type to basic type conversion

1835


Can abstract class have normal methods?

610


• What are the desirable attributes for memory managment?

1725






What is oops in programming?

564


hi all..i want to know oops concepts clearly can any1 explain??

1681


What is overloading in oops?

596


What is object and class in oops?

588


Who invented oop?

656


What is difference between class and object with example?

562


What is new keyword in oops?

590


What is encapsulation with example?

578


is there any choice in opting subjects like 4 out of 7

1728


What are the 3 pillars of oop?

613