IEEE UVCE SUN MICROSYSTEMS
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.
2]b] 5. The float 5.99999 is downsized to integer variable (the fractional
part is neglected).
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.
5] a] Hi. It is because any fractional value is stored as double precision
value.
6] d] 7. Comma operator has left to right precedence.
7] c] 4 8 10. 'f' and 'l' typecasts the double precision number 3.14 to single
precision value and long double respectively.
8] Error: Nested comments are not allowed in C.
9] 1 1 -1 -1. '%' operator takes only sign of numerator into account.
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.
11] Error: Syntax of switch is wrong. It is only default.
12] a=12.56
area=12.00
13] 4 4.In gcc integer is 4 bytes since it is 4 bytes.
IEEE UVCE SUN MICROSYSTEMS
14] d] recursive calls are challenging(infinetely...)
15] b] It runs an infinite loop without printing anything.
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
19] Error: Continue keyword cannot be usedin switch statement.
20] c] 20 10. In C, variables cannot be defined in between a code but can be
definetely declared at start of a block.
PART 2:
1] The base addresses of the matrices to be multiplied is supposed to be sent
to the function in which the multiplication takes place. Collect the base
address of result in a pointer and display it.
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:
1] b] Solaris c]Linux a] Windows
Windows is pretty unstable compared to UNIX variants. Solaris has a
larger uptime because of the predictive self-healing feature in it.
IEEE UVCE SUN MICROSYSTEMS
2] a] No all programs require some memory, however small at run-time.
b] Yes most of dynamic tools can be plugged into programs at run-time.
3] a] There are no viruses for Solaris.
b] There are many. We leave it to you guys (create, if you want a few).
4] They are mail clients.
(Please do contact Ananth or Jayanth for further clarifications).