BE Computer Engineering (IOE, TU) Computer Programming in C (IOE, CT 401) Question Paper 2078
This is the official BE Computer Engineering (IOE, TU) Computer Programming in C (IOE, CT 401) question paper for 2078, as set in the regular annual examination. It carries 80 full marks and a time allowance of 180 minutes, across 11 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 2078 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, clearly explaining the role of preprocessor directives, the main() function, declarations, and statements. (b) What is meant by a token in C? List and briefly explain the different categories of tokens. (c) Differentiate between the storage classes auto, static, extern, and register with respect to their scope, lifetime, and default initial value.
(a) Distinguish between call by value and call by reference with a suitable example for each. (b) Write a C program using a recursive function to compute the factorial of a number entered by the user, and explain how the recursion unwinds for an input of 4. (c) How does passing a one-dimensional array to a function differ from passing an ordinary variable?
(a) What is a pointer? Explain the relationship between arrays and pointers with reference to how the expression a[i] is evaluated by the compiler. (b) Write a C program that reads a string from the user and counts the number of vowels, consonants, and digits in it using pointer notation (do not use array subscripting). (c) Explain the meaning of the declaration int *p[10]; and how it differs from int (*p)[10];.
(a) Define a structure named Student containing fields for roll number, name, and marks in three subjects. Write a C program that reads records of n students, computes the total and average marks of each, and writes the records to a file named student.dat. (b) Explain the difference between a structure and a union in terms of memory allocation, giving a suitable diagram. (c) Differentiate between text mode and binary mode of opening a file.
Section B: Short Answer Questions
Attempt all / any as specified.
(a) Explain operator precedence and associativity with an example. Evaluate the expression a = 5 + 3 * 2 - 8 / 4 % 3 step by step, showing the value of a. (b) What is the difference between i++ and ++i? Determine the output of the following code:
int i = 5, j;
j = i++ + ++i;
printf("%d %d", i, j);
(a) Differentiate between the while loop and the do-while loop with a flowchart for each. (b) Write a C program using a switch statement that takes a single character operator (+, -, *, /) and two operands from the user and performs the corresponding arithmetic operation, handling division by zero appropriately.
(a) Write a C program to read a 3x3 matrix and find the transpose of the matrix, displaying both the original and the transposed matrix. (b) Explain any four standard string-handling library functions in C with their syntax and a one-line description of each.
(a) Differentiate between printf() and scanf() functions, explaining the meaning of the format specifiers %d, %f, %c, and %s. (b) What will be the output of the following program? Justify your answer.
#include <stdio.h>
int main() {
int a = 10;
float b = 3;
printf("%d\n", a / (int)b);
printf("%.2f\n", a / b);
return 0;
}
(a) What is dynamic memory allocation? Explain the use of malloc(), calloc(), and free() with their syntax. (b) Write a C program that dynamically allocates memory for an array of n integers entered by the user, finds the largest element, and frees the allocated memory before exiting.
(a) List and explain the different file opening modes (r, w, a, r+, w+, a+) used with fopen(). (b) Write a C program that opens an existing text file, reads it character by character, copies its contents to another file, and counts the total number of lines in the file.
Write a C program to generate and display the first n terms of the Fibonacci series, where n is entered by the user, using an iterative approach. Briefly explain how the same result could be achieved using recursion.