Delicious Digg Facebook Favorites More Stumbleupon Twitter

Friday 21 September 2012

program for calculator



              #include<stdio.h>
              main()
             {
                int a,b;
                char op;
                clrscr();
                printf("enter the operator(+,-,*,/)\n:");
                scanf("%c",&op);
                printf("enter the values of a,b:\n");
                scanf("%d%d",&a,&b);
                if(op == '+')
                printf("\n%d+%d=%d",a,b,a+b);
                else if(op == '-')
                printf("\n%d-%d=%d",a,b,a-b);
                else if(ch == '*')
                printf("\n%d*%d=%d",a,b,a*b);
                else if(ch == '/')
                printf("\n%d/%d=%d",a,b,a/b);
                else
                printf("sorry invalid operator");
                getch();
              }             

                              
                  
                  

0 comments:

Post a Comment