Programming in C Can someone help me figure out what is wrong with my code?

profilejvlieti4440

Programming in C Can someone help me figure out what is wrong with my code? I am trying to create a simple calculator in C. I am using Code Blocks and my code won't build and run.

 

#include<stdio.h>

#include<stdlib.h>

int main()

{   int n,num1,num2,result;

    char option;

do{

    printf("\nwhat operation do you want to do?\n");

    printf("press 1 for addition\n");

    printf("press 2 for subtraction\n");

    printf("press 3 for multiplication\n");

    printf("press 4 for division\n");

    scanf("%d",&n);

    printf("please enter a number\n");

    scanf("%d",&num1);

    printf("please enter a second number\n");

    scanf("%d,&num2);

    switch(n)

    {

      case 1:result=num1+num2;

             printf("addition of two numbers is %d,result");

             break;

      case 2:result=num1-num2;

             printf("subtraction of two numbers is %d,result");

             break;

      case 3:result=num1*num2;

             printf("multiplication of two numbers is %d,result");

             break;

      case 4:result=num1/num2;

             printf("division of two numbers is %d,result");

             break;

      default:printf("wrong input");

      }

      printf("do you want to continue y/n?\n");

     option=getche();

}while(option=='y');

      getch();

      return 0;

   }

 

    • 10 years ago
    • 3
    Answer(2)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      calculator.zip

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      calculator.zip
    Bids(0)