Week-2-Jan-2025 Assignment Solution
Week-2-Jan-2025 Assignment Solution
Solution: (c) Variable name must not begin with a digit. So, ‘123Var’ is invalid variable
declaration in C.
a) Sequential
b) Parallel
c) Multi-threading
d) None of these
a) I and II
b) II and III
c) I, II and IV
d) All of the above
5. A function is
6. What will be the output? [N.B: - .2f is used to print up to 2 decimal places of a
floating point number]
#include <stdio.h>
int main()
{
float a = 5.0;
printf ("The output is %.2f", (9/5)*a + 7);
return 0;
}
a) 28.2
b) 21.00
c) 16.00
d) 12.00
Since 9 and 5 are integers, integer arithmetic happens in subexpression (9/5) and
(9/5) will evaluate to 1 (not 1.8). The calculation will be as follows: (9/5)*a+10 =
1*5.0+7 = 12.00
a) 106
b) 70
c) 79
d) Compiler error
Solution: (c) In 0110, the leading zero indicates that the number is in octal (base-8)
representation of 72. Thus 72 +7 = 79 will be stored in var.
8. If integer needs two bytes of storage, then the minimum value of a signed integer in C would
be
a) −(216 − 1)
b) 0
c) −(215 − 1)
d) −215
ASSIGNMENT 2 SOLUTION
Solution: To find the minimum value of a signed integer in C, given that it uses 2 bytes
of storage:
a) 9
b) 0
c) 1001
d) Compilation Error
Before the line a=9;, we need to declare the variable a. Since we are using %d in printf,
it's likely meant to be an integer:variable. therefore a compilation error.
Solution: 18.50
The pre-processing replaces fun(2) with (2*2-2). Thus fun(2)= fun(2*2-2) which
evaluates to 2. so, i=37.0/2=18.50