[Total Time: 2½ Hours]
[Total Marks: 75]
N.B. 1) All questions are compulsory.
2) Figures to the right indicate marks.
3) Illustrations, in-depth answers, and diagrams will be appreciated.
4) Mixing of sub-questions is not allowed.
____________________________________________________________________________________________________________________________
Q. 1) Attempt All (Each of 5Marks) (15M)
(A) Multiple Choice Questions
i) What will be the output of the following C code?
#include <stdio.h>
void main()
{
while ()
printf(“In while loop “);
printf(“After loop\n”);
}
a) In while loop After loop
b) Compile Time Error
c) After loop
d) Infinite loop
ii) What will be the output of the following C code?
#include <stdio.h>
void main()
{
switch (printf(“Do”))
{
case 1:
printf(“First\n”);
break;
case 2:
printf(“Second\n”);
break;
default:
printf(“Default\n”);
break;
}
}
a) Do
b) DoFirst
c) DoSecond
d) DoDefault
iii) What is the output of the following C code?
#include <stdio.h>
int main()
{
void foo(), f();
f();
}
void foo()
{
printf(“2 “);
}
void f()
{
printf(“1 “);
foo();
}
a) Compile Time Error
b) 1 2
c) 2 1
d) Depends on compiler
iv) Which of the following logical operations can be applied to pointers?
(Assuming initialization int *a = 2; int *b = 3;)
a) a | b
b) a ^ b
c) a & b
d) None of the mentioned
v) What is the output of the following code?
#include<stdio.h>
main()
{
int n,i;
n=f(6);
printf(“%d”,n);
}
f(int x)
{
if(x==2)
return 2;
else
{
printf(“+”);
f(x-1);
}
}
a) ++++2
b) +++++2
c) +++++
d) 2
B) Fill in the blanks
(tokens, int, functions, unary operation, contiguous, strcmp(),single operation, void, continuous, strcat())
i) The ______ library function is used to concatenate one string to the end of another string.
iiv A C program is basically a collection of____________.
iii) In the C programming language, array elements always have ____________ address.
iv) An operation with only one operand is called ______ operation.
v) The default return type of a function in C is ______.
C) Give short answers for the following:
i) What is a structure? Give an example
ii) What is a pointer?
iii) Write the syntax of fopen?
iv) What is an escape sequence?
v) Give syntax of do..while() loop.
Q. 2) Attempt the following (Any THREE) (Each of 5Marks) (15M)
a) Differentiate between compilers and interpreters.
b) What are the various data types available in C? Explain the memory size and range of data possible.
c) What are bitwise operators? Explain citing an example for each.
d) Write a ‘C’ program to accept number and find out whether it is even or odd.
e) Distinguish between If-else Structure and Switch Statement. Give example to support your answer.
f) Trace the output of the following code:
i) void main( )
{
int a = 4;
switch (a)
{
default : printf(“In default”);
case 1 : printf(“In 1”);
break;
case 2 : printf(“In 2”);
break;
}
}
ii) void main( )
{
int i = 0, x = 0;
for (i = 1; i < 10; i ++)
{
if (i %2 = = 1)
x = x + 1;
else
x – –;
printf(“%d”, x);
}
}
Q. 3) Attempt the following (Any THREE) (Each of 5Marks) (15M)
a) Write syntax and explain the use of the following functions:
i) getch( )
ii) getche( )
iii) getchar( )
iv) getc( )
v) gets()
b) Differentiate between pass by value and pass by reference. Support your answer with an example
c) How are strings in C implemented? Explain with an example.
d) What is an array? What are the advantages and disadvantages of an array?
e) Write a program to copy one string to another without using standard library function.
f) Trace the output of the following code
int fun(int n, int *fg)
{ int t, f;
if(n <= 1)
{
*fg = 1;
return 1;
}
t = fun(n-1, fg);
f = t + *fg;
*fg = t;
return f;
}
int main( )
{
int x = 15;
printf ( “%d\n”, fun (5, &x));
return 0; }
Q. 4) Attempt the following (Any THREE) (Each of 5Marks)(15M)
a) What are nested structures? Explain with an example.
b) What are the types of files available in C? Explain the various file opening modes in C.
c) Write a note on unions in C. Support your answer with an example.
d) Explain malloc() and calloc() with syntax and example. How are they different?
e) Write a program to accept Student information (Roll no., name, percentage of marks) for ‘n’ students (Dynamically allocated). Store this in file and display it in well format (Accept ‘n’ from the user.)
f) Trace the output of the following code:
i. # include <stdio.h>
void main()
{ int i = 3, *j, k;
clrscr();
j = &i;
printf(“%d\n”, i**j * i+ *j);
}
ii. # include <stdio.h>
void main()
{ int x[25];
x[0] = 100;
x[24] = 400;
printf(“\n%d%d”, *x, *(x+24)+*(x+0));
}
Q. 5) Attempt the following (Any THREE) (Each of 5Marks) (15M)
a) Give the difference between while() and do..while() loops. Use an example to support your answer.
b) Explain any 2 library functions provided in ‘C’ language to manipulate strings.
c) Write a program using the recursive function to find the factorial of a number accepted from the user.
d) Write a program in C to accept a string and check if the string is palindrome or not. Print a suitable message.
e) Explain the following with declaration syntax and example
i) pointer to array
ii) array of pointers
______________________________________________________________________________________________________________________________________________________