C++ newbie ... confuzzled!

D

Delboy

can anyone please tell me what i did wrong here?
i'm confuzzled...i'm new to c++ and i wrote this just for practice with the
switch function!
any help will be great
thanks

------

#include <iostream.h>
int main()
{
int Number1;
int Number2;
char Operator;
cout << "Please Type A Number: " << "\n";
cin >> Number1;
cout << "Please Type Another Number: " << "\n";
cin >> Number2;
cout << "Please Choose An Operator (+; -; *; /): " << "\n";
switch(Operator)
{
case '+' : cout << Number1 + Number2;
break;
case '-' : cout << Number1 - Number2;
break;
case '*' : cout << Number1 * Number2;
break;
case '/' : cout << Number1 / Number2;
break;
}
return 0;
}
 
R

red floyd

Delboy said:
can anyone please tell me what i did wrong here?
i'm confuzzled...i'm new to c++ and i wrote this just for practice with the
switch function!
any help will be great
thanks
Non-standard header.

int main()
{
int Number1;
int Number2;
char Operator;
cout << "Please Type A Number: " << "\n";
cin >> Number1;
cout << "Please Type Another Number: " << "\n";
cin >> Number2;
cout << "Please Choose An Operator (+; -; *; /): " << "\n";

Where do you get Operator from? YOu never input it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top