/ Undifined / 11 - WAP that takes two operands and one operator from the user and perform the operation and prints the result by using Switch statement.

11 - WAP that takes two operands and one operator from the user and perform the operation and prints the result by using Switch statement.

WAP that takes two operands and one operator from the user and perform the operation and prints the result by using Switch statement.
#include <stdio.h>
#include <conio.h>
void main()
{
   int a, b, c;
   char ch;
   clrscr() ;
   printf("Enter your operator(+, -, /, *, %)\n");
   scanf("%c", &ch);
   printf("Enter the values of a and b\n");
   scanf("%d%d", &a, &b);
 
   switch(ch)
   {
      case '+': c = a + b;
        printf("addition of two numbers is %d", c);
        break;
      case '-': c = a - b;
         printf("substraction of two numbers is %d", c);
         break;
      case '*': c = a * b;
         printf("multiplication of two numbers is %d", c);
         break;
      case '/': c = a / b;
         printf("remainder of two numbers is %d", c);
         break;
      case '%': c = a % b;
         printf("quotient of two numbers is %d", c);
         break;
      default: printf("Invalid operator");
         break;
   }
   getch();
}
Output 
Enter you operator(+, -, /, *, %)
+
Enter the values of a and b
1 3
addition of two numbers is 4

about author

Blogger Sens it website about blogger templates and blogger widgets you can find us on social media
Previous Post :Go to tne previous Post
Next Post:Go to tne Next Post

No comments:

Post a Comment