You are on page 1of 2

Birla Institute of Technology and Science Pilani, Hyderabad Campus

Summer Term 2015 Computer Programming CS F111 Test 1 Exam


Date: 09.06.2015
Duration: 60 minutes
Type: Closed Book
Max Marks:20
------------------------------------------------------------------------------------------------------------------------------Instructions :
1. Attempt all questions.
2. Assume that #include<stdio.h> is there in all the code segments given in the
questions.
------------------------------------------------------------------------------------------------------------------------------1. Answer the following question using TRUE (T), FALSE(F)
[5 Marks]
a. while (i =< 10) statement in C code is correct.
b. The word main is a reserved word in C language.
c. while loop body , executes atleast one time irrespective of condition is either true or
false
d. In stages of compilation, during linking stage the following statement
#include<stdio.h> gets replaced by the contents of the file stdio.h

e. For the following statement


a=0;
a= (a=0)? 2:3;
printf(%d,a);
Output is 2
2. Give output for the following problem

[1 marks * 5 = 5 marks]

a.)

b.)

int main()
{
int a = 10, b = 11, c = 15;
if(c <= 20 && ++a <= b)
printf("Yes\n");
else
printf("No\n");

int main()
{
int j = 4;
(!j != 1 ? printf("Welcome\n") : printf("Good Bye\n"));
return 0;
}

printf("a = %d\n", a);


return 0;
}

c.)
int main()
{
int i = 65;
char j = 'A';
if(i == j)
printf("C is WOW\n");
else
printf("C is a headache\n");
return 0;
}

d.)
int main()
{
char ch = 100;
char r = ch + 28;
printf("r = %d\n", r);
return 0;
}

e.)
int main()
{
int x = 4, y = 0, z;
while(x >= 0)
{
x--;
y++;
if(x == y)
continue;
else
printf("%d %d\n", x , y);
}
return 0;
}

3. Draw a flowchart for the following problem


Problem is to read N and generate the following pattern for N lines
for N = 4
1
23
456
78910

[5 marks]

4. Write a C Program to input a positive integer number (having more than 1 digit) and find the
sum of first digit and last digit.
[5 marks]
for example if input: 12345 then output: 6 ( reason 1 + 5 = 6 )

You might also like