Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Oct 6, 2010 3:56:58 GMT
#include <cstdio>
int menu, num1, num2,total;
int main(){ printf("Enter two numbers:\n"); scanf("%d",&num1); scanf("%d",&num2); printf("Please choose an option\n1. Add\n2. Subtract\n3. Multiply\n4. Divide\n"); scanf("%d", &menu); if(menu==1){ total=num1+num2; printf("total=\n%d",total); } if(menu==2){ total=num1-num2; printf("total=\n%d",total); } if(menu==3){ total=num1*num2; printf("total=\n%d",total); } if(menu==4){ total=num1/num2; printf("total=\n%d",total); } if(menu>4){ printf("Please Try Again!\n"); } return 0; } Made it ages ago =P It's ok..... you will have to compile it though
|
|
|
Post by spartans63 on Oct 8, 2010 13:13:04 GMT
You cstdio.h for that? Why not rewrite it to use isotream and cin and cout?
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Oct 8, 2010 18:10:50 GMT
Well about a year ago at school they taught me that and use cstdio. I haven't learnt the cin and cout much. I've recently been concentrating on JavaScript.
|
|
John Wankel
Elite Poster
Coding for you one step at a time[M:0]
Posts: 399
|
Post by John Wankel on Oct 8, 2010 20:13:42 GMT
That looks pretty good. I agree though, learn cin and cout
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Nov 28, 2010 6:06:50 GMT
Wow, you posted that a while ago John. I plan on uping my web coding first to a higher level
|
|
prads
Elite Poster
[M:0]
It's a shame that PI isn't an integer :(
Posts: 361
|
Post by prads on Nov 28, 2010 6:24:19 GMT
Guess they didn't teach you switch statement, did they? Anyway, nice code!
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Nov 28, 2010 6:25:41 GMT
No.... they didn't teach us much ;D
|
|