Ask the user for a number If the number is less than 100 the
Ask the user for a number. If the number is less than 100, then display the number times 22. If the number is more than 100, then display the number divided by 22. Otherwise, just display the number. Use only integers
Solution
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<\"Enter an integer: \";
cin >> n;
cout<<\"Result: \";
if(n < 100){
cout<<(n*22)<<endl;
}
else if(n > 100){
cout<<( n / (double)22)<<endl;
}
else{
cout<<n<<endl;
}
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter an integer: 9
Result: 198
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter an integer: 110
Result: 5
sh-4.2$ main
Enter an integer: 100
Result: 100
