First off, I want to say that I am brand new to programming (I started yesterday). I thought that for my first actual project I would make a calculating program with the four basic functions of addition, subraction, multiplication, and division. I made one that works, but my problem is that I couldnt find a way to make the program so that you actually have to input the +, -, *, and /. Is there any way to do this? Here's what I have right now.
Code:#include <stdio.h> int main () { int v; int w=1; int x; int y; int z; do { printf("Add-1, Subtract-2, Multiply-3, Divide-4: "); scanf("%d", &z); if(z==1) { printf("Type the two numbers you would like to add: "); } else if(z==2) { printf("Type the two numbers you would like to subtract: "); } else if(z==3) { printf("Type the two numbers you would like to multiply: "); } else if(z==4) { printf("type the two numbers you would like to divide: "); } else printf("Reset?"); if(z) { scanf("%d", &x); scanf("%d", &y); if(z==1) { v = x + y; } else if(z==2) { v = x - y; } else if(z==3) { v = x * y; } else if(z==4) { v = x / y; } printf("The result is %d\n", v); getchar (); } } while (w); }



LinkBack URL
About LinkBacks



