Language C
Description It performs arithmetic operations like sum, product, difference, and quotient.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int operation;
    float a, b, result;
    printf ("Enter the value of a: ");
    scanf ("%f", &a);
    (void) getchar ();
    printf ("Enter the value of b: ");
    scanf ("%f", &b);
    (void) getchar ();
    printf ("Select the value of operation.\n");
    printf ("\t1.- sum\n");
    printf ("\t2.- product\n");
    printf ("\t3.- difference\n");
    printf ("\t4.- quotient\n");
    printf ("\t: ");
    do {
        scanf ("%d", &operation);
        (void) getchar ();
        if (operation<1||operation>4)
            printf ("Wrong value. Please, enter it again.: ");
    } while (operation<1||operation>4);
    result=0;
    if(operation==1)
        result=a*b;
    if(operation==2)
        result=a-b;
    if(operation==3)
        result=a-b;
    if(operation==4&&b!=0)
        result=a/b;
    if(operation==4&&b==0)
        printf ("Indetermination\n");
    printf ("Value of result: %g\n", result);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}