END TERM EXAMINATION
FIRST SEMESTER [BCA] DEC-2019
Paper Code: BCA-105
Subject: Introduction to Programming Languages Using C
Time: 3 Hours
Maximum Marks: 75
Note: Q. No. 1 is compulsory. Attempt one question from each unit.
- Q1. Answer briefly (Any Five): (5x5=25)
- (a) Discuss pre processor directives in c.
- (b) What do you understand by dynamic memory allocation? Explain malloc(), calloc(), realloc() and free() functions with their syntax and a suitable example.
- (c) Write a short note on storage classes in c.
- (d) Discuss the various operators in c.
- (e) Explain the different loop structures in c through suitable examples.
- (f) Distinguish between a structure and a union through a suitable example.
UNIT I
- Q2. (a) Explain the if..else statement with all its variations. Compare it with switch..case. Write a c program that demonstrates the difference between the two. (7)
- (b) Write a c program to test whether a given integer is a prime number or not. Display an appropriate message in the output. (5.5)
- Q3. (a) What do you understand by type casting? Why is it required? Explain Using An example (6)
- (b) Write a C program to display the following pattern (for n lines): (6.5)
- 1
- 1 2
- 1 2 3
- 1 2 3 4
UNIT II
- Q4. (a) Write a short note on recursion. (5.5)
- (b) Write a complete c program that displays the first n Fibonacci numbers through a recursive function Fibonacci. (7)
- Q5. (a) Differentiate between call by value and call by reference methods of passing parameters to functions using an appropriate example. (7)
- (b) Write a c function that searches for an element x in an array of integers. (5.5)
UNIT III
- Q6. (a) What are structures and what are Bit Field structures? How are they different from Unions? (4)
- (b) Explain how structures can be passed as parameters to functions, by value and by reference? And how they can be returned from functions? (6)
- (c) What do you understand by pointers to structures? How can we access the elements of a structure through a pointer to the structure? (2.5)
- Q7. (a) Write a C program that creates and displays a text file on screen. (7.5)
- (b) Discuss the following file handling functions, through syntax and examples: (5)
- i) fopen()
- ii) fclose()
- iii) fseek()
- iv) fwrite()
- v) fread()
UNIT IV
- Q8. (a) Write a program that counts the number of occurrences of a character in a given string without the use of any string handling library functions. (7.5)
- (b) Explain any five string handling functions from string.h with syntax and example. (5)
- Q9. (a) Write a short note on header files. (2.5)
- (b) Explain any two functions each from the following header files: Stdio.h, math.h, stdlib.h, ctype.h, string.h (10)