Answer to Question #48366 in C++ for ankita

Question #48366
take a number if it is more than 100 subtract 20 from it otherwise add 50 to it display the new nos
1
Expert's answer
2014-10-30T04:25:58-0400
// take a number if it is more than 100 subtract 20 from it otherwise add 50 to it display the new nos
#include <iostream>
using namespace std;
int main()
{
int number;
int result=0;
cout << "please enter number" << endl;
cin>>number;
if(number>100)
{
cout << "number is > 100" << endl;
result=number-20;
}
else
{
cout << "number is < 100" << endl;
result=number+50;
}
cout << "result = " << result<<endl;
return 0;
}
// compiling on Linux:
// g++ question.cxx -o question
// ./question


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS