Computer Science, asked by prishakapoor84091, 8 months ago

Why is this command not working cls print "this is a calculator for multiplication, division, addition and substraction" cls input "enter 1 for addition 2 for substaction 3 for multiplication and 4 for division"; f if f = 1 then input "enter a number:"; a cls if f = 1 then input "another number:"; b c = a + b if f = 1 then print "the answer is:"; c cls if f = 2 then input "enter a number:"; d cls if f = 2 then input "another number:"; e r = d - e if f = 2 then print "the answer is:"; r cls if f = 3 then input "enter a number:"; g cls if f = 3 then input "another number:"; h i = g * h if f = 3 then print "the answer is:"; i cls if f = 4 then input "enter a number:"; j cls if f = 4 then input "another number:"; k l = j / k if f = 4 then print "the answer is:"; l end

Answers

Answered by venky2venna
1

Answer:

#include < stdio.h >  

 

int main()  

{  

   int a, b;  

   char choice;  

 

   printf("Enter your choice\n");  

   printf("a. Addition\nb. Subtraction\nc. Multiplication\nd. Division\n");  

   scanf("%c", &choice);  

 

 

  printf("Enter 2 integer numbers\n");  

  scanf("%d %d", &a, &b);  

 

 

   switch(choice)  

   {  

       case 'a': printf("%d + %d = %d\n", a, b, (a+b));  

               break;  

 

       case 'b': printf("%d - %d = %d\n", a, b, (a-b));  

               break;  

 

       case 'c': printf("%d x %d = %d\n", a, b, (a*b));  

               break;  

 

       case 'd': if( b != 0)  

                   printf("%d / %d = %d\n", a, b, (a/b));  

               else  

                   printf("Number can't be divided by 0\n");  

               break;  

 

       default: printf("You entered wrong choice\n");  

                break;  

   }  

 

   return 0;  

}  

this may serve your need..

Similar questions