PERFORM ARITHMETIC OPERATIONS

#include<stdio.h> #include<conio.h> main() {             int a,b, res;             int op;             clrscr(); ...

#include<stdio.h>
#include<conio.h>
main()
{
            int a,b, res;
            int op;
            clrscr();
            printf("ENTER A,B VALUES \n");
            scanf("%d%d",&a,&b);
printf("\n1:SUM\n 2:SUBSTRACTION\n 3:MULTPLICATION\n
 4:DIVISION \n");
            printf("ENTER YOUR CHOICE \n");
            scanf("%d",&op);

            switch(op)
            {
               case 1:
                 res=a+b;
                 printf("%d+%d=%d",a,b,res);
                 break;

                case 2:
                  res=a-b;
                  printf("%d-%d",a,b,res);
                   break;

                 case 3:
                    res=a*b;
                    printf("%d*%d",a,b,res);
                    break;

                  case 4:
                     res=a/b;
                     printf("%d/%d",a,b,res);
                     break;

                   default:
                      printf("\n INVALID CHOICE");
                      break;
            }
            getch();
}


Output:

arithmetic operations



Related

C Programs 7296405918604916486

Post a Comment

emo-but-icon

item