This is another easy exercise to test your knowledge of the fundamentals. In main(), ask the user to enter two integers. Pass those two integers to a function that will subtract one number from another. This function must also output the answer to the user.
Output:
Enter two integers (separated by a space) and this program will subtract them: [user enters: 5 7]
5 - 7 = -2
void Sum(int a,int b)
{
cout << "Enter two integers" << endl;
cin >> a >> b;
cout << a << " - " << b << " = " << a - b << endl;
}
int main()
{
int a,b;
Sum(a,b);
}
Comments
Leave a comment