#include <iostream>
#include <cstdlib>
usingnamespace std;
int main()
{
int operation;
int howmany;
int num;
int temp;
int answer;
cout << "Here are your options: " << endl << endl;
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cin >> operation;
switch(operation){
case 1:
for (int i=1; i<=num; i++)
{
cout << "enter how many numbers you want to use"
cin>>num;
temp=temp+num;
}
cout<<"The sum of the "<<num<<" numbers is: "<<temp;
cout<<"The sum of the "<<num<<" numbers is: "<<answer;
}
cin.get();
return 0;
}
ok i know the indentaion is wrong, im just trying to get it to work. here are the erors:
C:\Users\\Desktop\c++\New folder\a\Untitled2.cpp||In function 'int main()':|
C:\Users\\Desktop\c++\New folder\a\Untitled2.cpp|31|error: a function-definition is not allowed here before '{' token|
C:\Users\\Desktop\c++\New folder\a\Untitled2.cpp|67|error: expected '}' at end of input|
C:\Users\\Desktop\c++\New folder\a\Untitled2.cpp|67|error: expected '}' at end of input|
||=== Build finished: 3 errors, 0 warnings ===|
wait...something is wrong...when i compile it works...i press 1 to add...i enter how many numbers i want to use....it doesnt let me choose the numbers and just prints a random number on the screen?
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main()
{
int operation;
int howmany;
int num;
int temp;
int answer;
cout << "Here are your options: " << endl << endl;
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cin >> operation;
switch(operation){
case 1:
cout << "enter how many numbers you want to use";
cin>>num;
for (int i=1; i<=num; i++)
{
temp=temp+num;
}
cout<<"The sum of the "<<num<<" numbers is: "<<temp;
cout<<"The sum of the "<<num<<" numbers is: "<<answer;
}
cin.get();
return 0;
}