Friday, 22 September 2017

Write a Program to accept two numbers and a operator (+, -, *, / from user and complete that particular operation only in C language


Visit this website and learn Php java and  Many more 

programmersbhawa.com

Friends, my today's program is that we will take two numbers from the keyboard and addition,substraction,multiply and Divide  it will only part in the same program with the help of switch case.
#include(stdio.h)
#include(conio.h)
main()
{
int n,rem,a,b;
char op;
clrscr();
printf("Enter Operator(+,-,*,/)...");
scanf("%c",&op);
printf("Enter numbers...");
scanf("%d%d",&a,&b);
switch(op)
{
      case '+' :
                        printf("Result : %d ",a+b);
                        break;
      case '-' :
                        printf("Result : %d ",a-b);
                        break;
     case '*' :
                       printf("Result : %d ",a*b);
                       break;
     case '/' :
                       printf("Result : %d ",a/b);break;
      default  :
                      printf("Invalid operator....");
}
getch();
}


No comments:

Powered by Blogger.