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 SPL in c++.

1 Answers  


write a function that takes an integer array as an input and finds the largest number in the array. You can not sort array or use any API or searching needs?

2 Answers   IBMS, Zycus Infotech,


What is the benefit of oop?

0 Answers  


What is the main difference between C++ and Java

11 Answers   TCS,


can you give the dynamic polymorphism types?

2 Answers   Wipro,






why constructor cannt be declar virtually? why destructor cannt be overloaded?

2 Answers   Infosys,


• What are the desirable attributes for memory managment?

0 Answers  


any one please tell me the purpose of operator overloading

0 Answers   Amazon,


what is polymorpsim? what are its types?

8 Answers  


what is function over loading?

5 Answers  


What are the advantanges of modularity

2 Answers  


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

3 Answers   Accenture, Cognizant, IBM,


Categories