make a simple calculator using switch case in c programming for calculator-99webcode

make a simple  calculator using switch case in c programming .

In this article we will  make a simple calculator using switch case in c programming .c program for calculator.


How to make a simple  calculator using switch case in c programming .



#include<stdio.h>

int main()

{

int ch;

int a,b;

int c;

printf("welcome to sr calsi");

printf("\nenter first number");

scanf("%d",&a);

printf("\nenter second number");

scanf("%d",&b);

printf("\nenter your choice\n1 for +\n2 for -\n3 for * \n4 for / \n5 for %");

printf("\nenter key ");

scanf("%d",&ch);

       if(ch==1)
{
               c=a+b;

printf("%d" ,c);

}

      else if(ch==2)

{

           c=a-b;

         printf("%d" ,c);

}

else if(ch==3)

{

c=a*b;

              printf("%d" ,c);

}

else if(ch==4)

{

c=a/b;

printf("%d" ,c);

}

       else if(ch==5)

{

c=a%b;

printf("%d" ,c);

}

        else

{

printf("oops you have entered wrong number");

}


}


Post a Comment (0)
Previous Post Next Post