Round up a Decimal number in c++..

example Note = 3.5 is as 4
3.3 is as 3

Answers were Sorted based on User's Feedback



Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3..

Answer / 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

Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3..

Answer / vimala

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

Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3..

Answer / pawarp

#include <iostream>
#include <cmath>
int main()
{
   float a;
   cout<<"Enter any float value to round up"<<endl;
   cin>>a;
   cout << round(a)<<endl;
   
   return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

What is the example of polymorphism?

0 Answers  


What is the importance of oop?

0 Answers  


When will a constructor executed?

5 Answers   TCS,


Program to check whether a word is in all capital letters

1 Answers  


what is overloading

3 Answers   MindCracker,






What is meant by multiple inheritance?

0 Answers  


Out of 4 concepts, which 3 C++ Follow?

1 Answers   TCS,


What does it mean when someone says I oop?

0 Answers  


What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.

2 Answers  


Can main method override?

0 Answers  


What is protected in oop?

0 Answers  


What do you mean by inline function?

6 Answers  


Categories