You are on page 1of 4

Fundamentals of C Programming >

Module Test Summary

Fundamentals of C Programming Test Summary

Your Marks 33%

1
If (a > b)
m = k;
else
m = n;
What will be the equivalent conditional statement (ternary expression) of the above
code?

Attempted answer: m = a > b ? k : n;

2 Which statement is true?

Attempted answer: Exclusive or symbol is XOR

Correct answer: Shift operators works in binary mode

3 How do you type cast a value of one data type to another?

Attempted answer: Just assign the value to a variable of desired date type

Correct answer:
By using instruction in this format (<desired data type>) <variable name>

4
#include <stdio.h>
#include
int main()
{
int i = 1;
switch(i)
{
case 1 : printf("%d",i);
case 2 : printf("%d",i+1);
case 3 : printf("%d",i+2);
case 4 : printf("%d",i+3);
}
}
What will be the output of the mentioned code?

Attempted answer: 1

Correct answer: 1234

5 What is the ceiling value of 10000.224 ?

Attempted answer: 10001

Correct answer: 10001.0

6 Which math function is used for calculating power of a number?


Attempted answer: pow()

7 Which format character may be used to print a floating point value?

Attempted answer: %f

8
#include <stdio.h>
int main()
{
int i, k;
for (i = 1; i <= 3; i++ )
{
for (k = 1; k <= i; k++)
printf("i");
printf("\n");
}
}
What will be the output of the following code?

Attempted answer:
123

12

Correct answer:
i

ii

iii

9
#include <stdio.h>
int main()
{
int x = 5, y = 10;
y = ++x - y + x++;
printf("%d %d", x, y);
}
What will be the output ?

Attempted answer:
7 3

Correct answer:
7 2

10
#include
int main()
{
int n = 487, d, e = 0;
while(n > 0)
{
e = e + n;
n = n / 10;
}
printf("%d", e);
}
Predict the output of the given program.

Attempted answer: 443

Correct answer: 539

11 What is the difference between switch-case and if statements?

Attempted answer: Switch case does not allow comparing high or low.

12
#include <stdio.h>
int main()
{
int n = 423, d, e = 0;
while(n > 0)
{
d = n % 10;
e = e + d;
n = n / 10;
}
printf("%d", e);
}
What will be the output?

Attempted answer: 5

Correct answer: 9

13 Which of the below does not belong to logical operator category ?

Attempted answer: !

Correct answer: &

14
#include <stdio.h>
int main()
{
int x , y=1;
for (x=1; x>=0; x++)
{
y = y + 1;
if (y > 5)
break;
}
printf ("%d", x);
}
What is the output of the program?

Attempted answer: 2
Correct answer: 5

15 Which of the statement is true for AUTO storage class?

Attempted answer: Auto have a local scope