For two integer inputs, and outputs the difference as required by the product provider.
Input format:
Enter two non-negative integer not more than a 100 and b in a row, with a space intermediate intervals, and to ensure that b is not 0.
Output formats:
a total of four lines, the format is:
[a] + [b] = [a+b]
[a] - [b] = [a-b]
[a] * [b] = [a*b]
[a] / [b] = [a/b]
Wherein a content with square brackets (e.g., [a], [b], [a + b], etc.) indicating the value of an integer or operation result, instead of use the actual value at the output.
And: if b can be a divisible, the a / b is an integer format to be output, otherwise a / b is output with two decimal format.
Tip: Note that the expression of space.
Input Sample 1:
63
Output Sample 1:
6 + 3 = 9
6 - 3 = 3
6 * 3 = 18
6/3 = 2
Input Sample 2:
86
Output Sample 2:
8 + 6 = 14
8 - 6 = 2
8 * 6 = 48
8/6 = 1.33
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d\n",a,b,a+b);
printf("%d - %d = %d\n",a,b,a-b);
printf("%d * %d = %d\n",a,b,a*b);
if (a%b == 0) {
printf("%d / %d = %d\n", a, b, a / b);
}
else {
printf("%d / %d = %.2f\n", a, b, ((double)a / (double)b));
}
return 0;
}