Solutions To C Coding Contest
Solutions To C Coding Contest
ANSWERS TO C CONTEST
PART 1:
1]d] none of the above. It is an error since the external variable has not been
defined. It is only declared.
3] The compiler reports an error telling that the prototype and function does
not match. The compiler takes the “display( );” in main as prototype and
not function call.
4] a]515.
7] c] 4 8 10. 'f' and 'l' typecasts the double precision number 3.14 to single
precision value and long double respectively.
10] 1. The return value of relational operators is one if true and zero if false.
But any non-zero input is true and zero input is false in C.
12] a=12.56
area=12.00
16] d]program runs into infinite loop since it is post decrement which never
happens. 5 is printed infinitely.
17] 20 10
18] c]10
PART 2:
2] Use a flag in the swap part of program. If flag is set go ahead else the
result is sorted.
3] If a and b are the two variables, use the following three statements:
a=a+b; b=a+b;
b=a-b; OR a=b-a;
a=a-b; b=b-a;
4] If we use union the data field must be same as pointer field. In structure
we can have any data field.
PART C: