Tuesday, July 28, 2009

I need help with c++?

im wrting a program that gives you an option in the beggining it says: cout %26lt;%26lt; "please select the opperation that you would like to complete A=addition B=subtraction C=multiplaction"


i want to writ an if statment like: if u choose this letter it will go to this part of the code and so on how would i do this

I need help with c++?
x = 0





cout %26lt;%26lt; "please select the opperation that you would like to complete 1=addition 2=subtraction 3=multiplaction"





cin%26gt;%26gt;x





if x = 1


code to add here


if x = 2


code to subtract here


if x = 3


code to multiply here

















buy a book and learn. If you need more help then message me and we will talk on aim or something.
Reply:char choice;


cout %26lt;%26lt; "Please select the operation that you would like to complete.\n


A. addition\n


B. substraction\n


C. multiplication\n";


cin %26gt;%26gt; choice;


switch (choice) {


    case 'A': case 'a':


       addition();


       break;


    case 'B': case 'b':


       subtraction();


       break;


    case 'C': case 'c':


       multiplication();


       break;


    default:


       error();


       break;


}


No comments:

Post a Comment