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

Difference between vector and array

2 Answers  


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

0 Answers  


What are the 4 pillars of oop?

0 Answers  


c++ program to swap the objects of two different classes

0 Answers  


1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

1 Answers   Nagarro,






what is the need of abstraction? what is abstraction?what is the abstraction for stack?

8 Answers   CTS, Verizon,


What is difference between function overloading and overriding?

1 Answers   emc2,


Why is polymorphism used?

0 Answers  


what is inline function?

3 Answers  


What is polymorphism give a real life example?

0 Answers  


me get an assignent n its question is this 1.creat a set as in math i.ea={1,2} 2.insert element in it3. delete element don,t repeat any element 4.union 5. intersection of two sets plz help me i always pray for u n send me at ayeshawzd@hotmail.com f u have c++ how to program 5th addition then it is the 10.9 question in 10th chapter exercise

1 Answers  


What is object and example?

0 Answers  


Categories