GREAT CALCULATOR
Problem Description
SRM Students decides to create a software to extend our help to Petty shops and Shops. In this regard the "STUDENT" team has selected a few students to complete the task. The task was monitored by a group of experts and the software was tested by a expert team from corporate.
The task is as follows when there are two items and if the shop keeper says 1 then it needs to add the two items. If the shop keeper yells 2 then the two items should be subtracted. And when the shop keeper tells 3 then the product of the items needs to be outputted. When shop keeper tells as 4 then the items should fight with one another.
Only Integer numbers as input
Input 1 = addition
Input 2 = Substraction
Input 3 = Multiplication
Input 4 = Division
CODING ARENA
#include <stdio.h>
int main()
{
char a;
int b,c;
scanf("%c",&a);
switch (a)
{
case '1':
scanf("%d %d",&b,&c);
printf("%d",b+c);
break;
case '2':
scanf("%d %d",&b,&c);
printf("%d",b-c);
break;
case '3':
scanf("%d %d",&b,&c);
printf("%d",b*c);
break;
case '4':
scanf("%d %d",&b,&c);
printf("%d",b/c);
break;
default:
printf("Invalid Input");
}
return 0;
}
Test Case 1
Input (stdin)1
35 36
Expected Output
71
Test Case 2
Input (stdin)5
23 45
Expected Output
Invalid Input
Invadid code
ReplyDelete