#include<stdio.h>
#include<stdbool.h>
#include<conio.h>
#include<math.h>
#include<string.h>
void main()
{
int num1, num2, sum;
char math;
printf("Enter num 1: ");
scanf("%d", &num1);
printf("enter num 2: ");
scanf("%d", &num2);
fflush(stdin);
printf("Enter calculation : ");
scanf("%C", &math);
switch(math)
{
case '+':
sum = add(num1, num2);
printf("%d + %d = %d",num1 ,num2, sum);
break;
case '-':
sum = sub(num1, num2);
printf("%d - %d = %d",num1 ,num2, sum);
}
}
int add(int a, int b)
{
int sum;
sum = a + b;
return sum;
}
int sub(int a, int b)
{
int sum;
a - b;
return sum;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter