Nirma University
Institute of Technology
Semester End Examination (RPR), May - 2017
B. Tech. in CL / CH / EE, Prerequisite Course
2CE106 Programming Languages
Roll / ‘Supervisor's Initial
Exam No. with Date
Time: 3 Hours Max Marks: 100
Instructions: 1, Attempt all questions.
Qa
B)
ec
Q2
A)
B)
D)
2. Figure to right indicate full marks.
3. Assume suitable assumptions and specify them.
4, Section wise separate answer book to be used.
SECTION -1
Do as directed: us]
Fill in the blanks: rc
1. ____ converts. assembly language into machine
language.
2. escape sequence is used to provide a vertical tab
while _____ is used for horizontal tab.
3. The operator has right to left associativity.
4. The value of the arithmetic expression: 2*b+3*(ac) is
where a= 8, b= -3 and c= 4 are integer variables.
State whether the following are True or False with justification: I
i There cannot be more than three dimensions for arrays.
ii, Including header files in the C program is optional.
iii, The default return type of main( ) function is void.
Describe the structure of a C program? Explain the different sections [8]
in detail.
Do as directed: [16]
Explain the working of << and >> operators using an example. 3
What will be the output of the following code for x = 12? 3
a=(x%2)21:0;
‘switch(a)
{
case 0:
printf{"Even Number’);
case 1:
printf'Odd Number’);
i
Explain the syntax of various forms of ‘if...else’ statements, 4
Write a C program to print integer part and fractional part of a floating 6
point number entered by a user. For example, if the number is 23.987,
then the integer part is 23 and the fractional part is 0.987
OR
Write a C program to print the sum of first N integer numbers using 6
the goto statement.
Tage. a2CE106 — Programming Languages
Q.3 Do as directed:
{16}
A) Write a C program to generate the following pattern: 6
1
23
456
78910
B) Write a menu driven C program to perform the operations of a 6
caleulator + - * /and %.
oR
B) Write a C program demonstrating formatted output of integer and float 6
numbers.
C) Write an algorithm to evaluate the polynomial 3x* - 2x? + 4x +5 where 4
the value of x is taken from the user.
SECTION =I
Q.4 Do as directed: [20]
A) Write a C program to find sum of n elements entered by user.
B) State and justify whether the following statement is true or false. [6]
i, main( is a user defined function
ii, Structure uses all the memory of its members and union uses the
largest member's memory space.
ili. The NULL pointer is a constant with a value of zero defined in
several standard libraries.
iv.A file is a collection of bytes stored ona secondary storage device,
which is generally a processor.
v.Commands used in preprocessor are _callled preprocessor
directives and they begin with “*” symbol.
vi.A linked list is held using a local pointer variable which points to
the first item of the list.
C) Find the error / output in the code segment. (Assume that necessary [8]
header files are included.)
i. int main( )
t
unsigned char;
FILE “fp;
fp=fopen( "trial", *r’);
ifftfp)
{
2
printf{"Unable to open file’);
exit( 1);
}
felose(fp);
return 0;
Page 2 of 32CE106 ~ Programming Languages
int main() 3
t
int theNum, total;
total = 1;
theNum = 5;
while (theNum > 1) {
total *= --theNum;
3
printf ("Yod", total);
return 0;
1
int main|void)
char *p ;
streatip, "abe’);
printf{"\n %s \n", p);
return 0;
}
Answer the following: 14]
Demonstrate the primary difference between C VARIABLE, C ARRAY 4
AND C STRUCTURE.
Write a program which explains concept of pointer and its advantages. 4
Write a C program using structure to add two distances entered by 6
user. Measurement of distance should be in inch and feet. (Note: 12
inches = 1 foot)
OR
Write a C program which counts the number of vowels, consonants, 6
digits and white-spaces in a string which is entered by the user.
Answer the following: 16}
Explain string functions functions in C with proper examples. 8
Explain and perform basic file operations using C. 8
OR
Write @ program to find the second largest & smallest elements in an 8
Array,
Page 3 0f 3