You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Input 3 Argume...

35 lines
783 B
C

/*
* C Program to Input 3 Arguments and Operate Appropriately on the
* Numbers
*/
#include <stdio.h>
void main(int argc, char * argv[])
{
int a, b, result;
char ch;
printf("arguments entered: \n");
a = atoi(argv[1]);
b = atoi(argv[2]);
ch = *argv[3];
printf("%d %d %c", a, b, ch);
switch (ch)
{
case '+':
result = a + b;
break;
case '-':
result = a - b;
break;
case 'x':
result = a * b;
break;
case '/':
result = a / b;
break;
default:
printf("Enter a valid choice");
}
printf("\nThe result of the operation is %d", result);
printf("\n");
}