CSC115 · TU past paper
C Programming 2079 question paper
The complete TU 2079 exam paper for C Programming (CSC115), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- Q1.10 marksFunction Arguments and Return TypesHideAnswer
Why do we need a break and continue statement? Define formal argument and actual argument in function with examples. Identify and list the errors in the following code.
int main() { int a, b, c scanf("%d%d%d, &a, &b, &c); sum(a, b, c); return -1; } void sum(int x, int y, int z) { int sum; sum = a + b + c; return sum; }[10]
- Q2.10 marksExit functionHideAnswer
What is the difference between exit() and exit(1)? Discuss the need of nested structure with an example. Write a program to find the value of x^y without using POW code.[10]
- Q3.10 marksDecision Making and LoopingHideAnswer
Write a program to demonstrate the following menu-driven program. The user will provide an integer and alphabet for making choice and the corresponding task has to be performed according as follow:A. Find Odd or Even B. Find Positive or Negative C. Find the Factorial value D. Exit The choice will be displayed until the user will give 'D' as a choice.[10]
- Q4.5 marksArithmetic operatorHideAnswer
How do you swap the values of two integers without using the third temporary variable? Justify with the example. [5]
- Q5.5 marksNested and Recursive FunctionHideAnswer
Write a program to find the sum of digits of a given integer using recursion. [5]
- Q6.5 marksConstants/ LiteralsHideAnswer
Differentiate between constant and literals. Why do we need to define the type of data? [5]
- Q7.5 marksIntroduction to ArrayHideAnswer
Write a program to find the second largest number in the given array of numbers. [5]
- Q8.5 marksArray of structureHideAnswer
Create a structure 'Employee' having Name, Address, Salary, and Age as member functions. Display the name of the employee having age between 40 and 50 and are living in Kathmandu. [5]
- Q9.5 marksPointers as Function ArgumentsHideAnswer
List any one advantage and disadvantage of the pointer. How do you pass pointers as function arguments? [5]
- Q10.5 marksInput Output Operations in FileHideAnswer
Suppose a file named 'Num.txt' contains a list of integers. Write a program to extract the prime numbers only from that file and write them on 'Prime.txt' file. [5]
- Q11.5 marksUnionHideAnswer
What is the advantage of the union over structure? List any four string library functions with the prototype. [5]
- Q12.5 marksLocal and Global VariableHideAnswer
Write short notes on: a. Local, Global, and Static variables b. Conditional Operator [5]