Write a program that prompts the user to enter two integer values. Store these values in int variables named val1 and val2. Write your program to determine the smaller, larger, sum, difference, product and ratio of these values and report them to the user.
Here is something I put together but I get plenty of error messages when trying to compile....
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
usingnamespace std
int main()
{
int val1=0;
int val2=0;
cout<<"Enter two integer values:\n";
cin>>val1>>val2
if (val1>val2) { cout>>" "<<val2<<" is smaller than "<<val1<<" and "<<val1<<" is bigger than "<<val2<<" \n"; }
if (val1<val2) { cout>>" "<<val1<<" is smaller than "<<val2<<" and "<<val2<<" is bigger than "<<val1<<" \n"; }
cout>>"The sum of "<<val1<<" and "<<val2<<" is "<<val1<< + <<val2<<" \n";
cout>>"The difference of "<<val1<<" and "<<val2<<" is "<<val1<< - <<val2<<" \n";
cout>>"The product of "<<val1<<" and "<<val2<<" is "<<val1<< * <<val2<<" \n";
cout>>"ratio of "<<val1<<" and "<<val2<<" is "<<val1<< : <<val2<<" \n";
}
cout uses << and not >>. You also have a lot of extra << in your cout statements especially where you attempt to perform the calculations - those are not needed.
For example, line 22 should look like this..
cout<<"The sum of "<<val1<<" and "<<val2<<" is "<< val1 + val2 <<" \n";
EDIT: cout's on lines 18 and 20 also need >> changed to <<
In function ‘int main()’:
Documents/program8.cpp:26:54: error: found ‘:’ in nested-name-specifier, expected ‘::’
cout<<"ratio of "<<val1<<" and "<<val2<<" is "<<val1 : val2<<" \n";
^
Documents/program8.cpp:26:49: error: ‘val1’ is not a class or namespace
cout<<"ratio of "<<val1<<" and "<<val2<<" is "<<val1 : val2<<" \n";
^