Professional Documents
Culture Documents
Assignment 2 July 2022 Solution
Assignment 2 July 2022 Solution
1. A function is
2. If an 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
Solution: (d) The first bit is used to indicate whether it is a signed or unsigned integer.
a) I and II
b) II and III
c) I, II and IV
d) All of the above
a)13
b)31
c)11
d)33
Solution: (b) 3 1
Here the program is swapping the values of the variables x and y. A temporary variable t is
used for the swapping purpose.
Solution: 18.50
The pre-processing replaces fun(2) with (2*2-2). Thus fun(2)=2, so, i=37.0/2=18.50
d) X_123_Var
Solution: (c) Variable name must not begin with a digit. So, ‘123Var’ is an invalid variable
declaration in C.
a) 6
b) 3
c) 4
d) Compilation error
Solution: (d) #define is a pre-processor and 6 is stored in a. Thus ‘a’ cannot be declared as a
variable. Thus, the compiler will return a compilation error.
10. The following C program swaps the value of two numbers without using any third
variable. What are the correct operations that need to be inserted inside the blanks?
#include <stdio.h>
int main()
{
int a=2, b=3;
printf("The values before swapping a = %d, b=%d", a, b);
_____; ______; _____;
printf("The values after swapping a = %d, b=%d", a, b);
return 0;
}