Code Scrappers


Simple Calculator - C program


                    #include<stdio.h>
                    #include<stdlib.h>

                    void main()
                    {

                        int a, b, c, choice;

                        printf("Enter the value of a:");

                        scanf("%d",&a);

                        printf("enter the value of b:");

                        scanf("%d",&b);

                        printf(" \n enter your choice \n 1.Add \n 2.Subtract \n 3.Multiply \n 4.Divide \n 5.Remainder \n");

                        scanf("%d", &choice);

                        switch(choice)
                        {
                            case 1: c = a + b;

                            printf(" Addition=%d", c);

                            break;

                            case 2: c = a - b;

                            printf(" Substraction=%d" , c);

                            break;

                            case 3: c = a * b;

                            printf(" Multiplication=%d", c);

                            break;

                            case 4: c = a / b;

                            printf(" Divide=%d", c);

                            break;

                            case 5: c = a % b;

                            printf(" Remainder=%d",c );

                            break;

                            default: printf(" Invalid Result");

                            break;

                        }

                    }

                



Output

        Enter the value of a:5

        enter the value of b:5

         enter your choice
         1.Add
         2.Subtract
         3.Multiply
         4.Divide
         5.Remainder

         3

         Multiplication = 25