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
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 |
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 |
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 |
How to reverse a sentence in c program ex: ram is a good boy answer: boy good a is ram
What is methods in oop?
What is advantage of inheritance?
What is data binding in oops?
what is mean by design pattern
What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++
What is multilevel inheritance explain with example?
What is command routing in MFC
Iam doing my project on instant messaging , if you any new ideas regarding this project ,please suggest it?
What does and I oop and sksksk mean?
What is difference between #define and const?
design class for linked list and include constructor,destructor,insert option. struct node { int node; struct node &ptr; }