BE Computer Engineering (IOE, TU) Computer Programming in C (IOE, CT 401) Question Paper 2079
This is the official BE Computer Engineering (IOE, TU) Computer Programming in C (IOE, CT 401) question paper for 2079, as set in the regular annual examination. It carries 80 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this Computer Programming in C (IOE, CT 401) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BE Computer Engineering (IOE, TU) Computer Programming in C (IOE, CT 401) exam or solving previous years' question papers, this 2079 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt all / any as specified.
(a) Describe the basic structure of a C program with the help of a suitable diagram, clearly explaining the role of preprocessor directives, the main() function, declarations, and statements. [6]
(b) What are the fundamental (primitive) data types available in C? Write a program that reads the radius of a circle from the user and prints its area and circumference, using an appropriate symbolic constant for the value of π. [6]
(a) What is recursion? Differentiate between a recursive function and an iterative function with respect to memory usage and execution. [4]
(b) Write a recursive C function to compute the factorial of a non-negative integer n, and trace the sequence of recursive calls and returns for n = 4. [4]
(c) Explain the difference between call by value and call by reference with a program that swaps the values of two variables. [4]
(a) What is a pointer? Explain the relationship between arrays and pointers in C, and show how the expression *(arr + i) is equivalent to arr[i]. [6]
(b) Write a C program that uses a pointer to traverse a character array and counts the number of vowels, consonants, and digits in a string entered by the user. [6]
(a) Distinguish between a structure and a union in C with respect to memory allocation, giving a suitable example of each. [4]
(b) Define a structure Student containing fields for roll number, name, and marks in three subjects. Write a program that reads records for n students, computes the total and percentage for each, and writes all records to a text file named students.txt. [8]
Section B: Short Answer Questions
Attempt all / any as specified.
(a) Differentiate between the increment operators in the expressions x = i++ and x = ++i. [2]
(b) Evaluate the following expression step by step, assuming int a = 5, b = 2, c; and state the final value of c:
c = a + b * 4 / 2 - a % b;
[4]
Write a C program using a switch statement that reads a single arithmetic operator (+, -, *, /) and two operands from the user, performs the corresponding operation, and prints the result. Handle the case of division by zero appropriately.
Write a C program that reads n integers into a one-dimensional array and finds the largest and smallest elements without using any built-in library functions.
Write a C program to check whether a string entered by the user is a palindrome or not (for example, madam is a palindrome). You may use standard string library functions where appropriate.
(a) What is a dangling pointer? How does it arise? [2]
(b) Explain the use of the functions malloc() and free() for dynamic memory allocation, and write a code fragment that dynamically allocates an array of n integers. [4]
(a) List the different file opening modes (r, w, a, etc.) available in C and state the purpose of each. [3]
(b) Write a C program that opens an existing text file in read mode and counts the total number of characters and lines in it. [3]
(a) Differentiate between #define and const for defining constants in C. [2]
(b) What is type conversion? Distinguish between implicit type conversion and explicit type casting with an example of each. [4]
(a) Differentiate between break and continue statements with a short example showing the effect of each inside a loop. [4]
(b) Write a user-defined function isPrime(int n) that returns 1 if n is prime and 0 otherwise, and use it in main() to print all prime numbers between 1 and 50. [4]