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 |
what is difference between c++ language and java language
Write a program to accept a number and to print numbers in pyramid format? for eg:for a no. 5 1 212 32123 4321234 543212345
What is polymorphism and example?
What is polymorphism used for?
polymorphism means?
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).
diff between Abstract class Interfaces?
Why is oop better than procedural?
Define a class to represent a bank account. Include the following members: Data Members: Name of the Depositor Account Number Type of Account Balance amount in the account Member Functions: To assign the initial values. To deposit an account. To withdraw an amount after checking the balance. Write a C++ main program to display account number, name and balance.
i hav very low percentage in 12th n BSCwhich is around 50.......coz it was just imposed on me 2 b a science graduate,nw m doin MCA n hav aggregate 74% ....what shud i answer if company's HR ask me about dis much low previous percentage??????
What is abstract class in oop?
What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass