Which error are you likely to get when you run the following program? main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for ( i = 0 ; i <= 9; i++) scanf ( "%s %f" , e[i].name, &e[i].sal ); }
Correct Answer
Floating point formats not linked
Programming problems
Search Results
1. In the following code in which order the functions would be called? a = ( f1 ( 23,14 ) * f2 ( 12/4) ) + f3() ;
Correct Answer: The order may vary from compiler to compiler Here the multiplication will happen before the addition , but in which order the functions would be called is undefined In an arithmetic expression the parentheses tell the compiler which operands go with which operators but do not force the compiler to evaluate everything within the parentheses first
2. What would be the output of the following program? main() { int i=2 ; printf ("\n%d%d", ++i, ++i ); }
Correct Answer: 0 0 1 That's what some of the compilers would give But some other compiler may give a different answer The reason is, when a single expression causes the same object to be modified and then inspected the behaviour is undefined
4. Point out the error, if any, in the following program. main() { int i = 4, j = 2; switch(i) { case 1 : printf (''\n To err is human, to forgive is against company policy."); break; case j : printf (''\n if you have nothing to do, don't do it here."); break; } }
8. There is a mistake in the following code. Add a statement in it to remove it. main() { int a; a = f (10, 3.14) ; printf ( " %d ", a ); } f (int aa, float bb) { return ( ( float ) aa + bb ); }
Correct Answer: Add the following function prototype in main (): float f ( int, float );
9. Point out the error, if any, in the following program. main() { int a = 10; void f(); a = f(); printf ( "\n %d", a ); } void f() { printf ( "\n Hi "); }