Really simple question - given two integers A and B whose absolute value does not exceed 100, you are asked to output the result in the format "A/B=quotient".
Input format:
The input gives two integers A and B (-100 <= A, B, <= 100) on the first line, separated by spaces.
Output format:
Output the result in one line: if the denominator is positive, output "A/B=quotient"; if the denominator is negative, wrap the denominator in parentheses and output; if the denominator is zero, the output quotient should be "Error" . The output quotient should have 2 decimal places.
Input sample 1:-1 2Sample output 1:
-1/2=-0.50Input sample 2:
1 -3Sample output 2:
1/(-3)=-0.33Input sample 3:
5 0Sample output 3:
5/0=Error
Code:
#include<stdio.h> intmain() { int i,j,n,m,k,t; scanf("%d %d",&n,&m); if(m==0) { printf("%d/0=Error",n); } else if(m>0) { printf("%d/%d=%.2lf",n,m,1.0*n/m); } else { printf("%d/(%d)=%.2lf",n,m,1.0*n/m); } return 0; }