TOPIC

Wrong answer

Abdulla Al Mamun asked 1 year ago

#include int main() { double A,B,C,D,E,a,b,c,d; scanf("%lf %lf %lf %lf",&a,&b,&c,&d); printf("A = %.6lf, B = %.6lf\n",a,b); printf("C = %.6lf, D = %.6lf\n",c,d); printf("A = %.1lf, B = %.1lf\n",a,b); printf("C = %.1lf, D = %.1lf\n",c,d); printf("A = %.2lf, B = %.2lf\n",a,b); printf("C = %.2lf, D = %.2lf\n",c,d); printf("A = %.3lf, B = %.3lf\n",a,b); printf("C = %.3lf, D = %.3lf\n",c,d); printf("A = %.3E, B = %.3E\n",a,b); printf("C = %.3E, D = %.3E\n",c,d); printf("A = %.0lf, B = %.0lf\n",a,b); printf("C = %.0lf, D = %.0lf\n",c,d); } why am i getting 5% error,while output is ok. N.B. while using codeblocks scientific notation prints 3 digits where as online compilers like https://www.onlinegdb.com/online_objectivec_compiler prints 2 digits.

Remember not post solutions. Your post may be reviewed by our moderators.

  • Joy replied 1 year ago

    You don't need to use .6f or .6lf. Just use %f or %lf. Compiler will know how much decimal it has to show as output.