Bachelors Level/First Year/First Semester/Science csit/first semester/c programming/syllabus wise questions

B.Sc Computer Science and Information Technology

Institute of Science and Technology, TU

C Programming (CSC115)

Year Asked: 2079, syllabus wise question

Arrays
1.
Write a program to find the second largest number in the given array of numbers. [5]
Control Statement
1.
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]
2.
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]
Elements of C
1.
Differentiate between constant and literals. Why do we need to define the type of data? [5]
2.
Write short notes on: a. Local, Global, and Static variables b. Conditional Operator [5]
File Handling in C
1.
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]
Functions
1.
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.

$\text{int main()\{} $

$\text{int a,b,c} $

$\text{scanf("\%d\%d\%d, \&a, \&b, \&c);}$

$\text{sum(a, b, c);}$

$\text{return -1;}$

$\text{\}}$

$\text{void sum(int x, int y, int z)\{}$

$\text{int sum;}$

$\text{sum = a + b + c;}$

$\text{return sum;}$
$\text{\}}$
[10]
2.
Write a program to find the sum of digits of a given integer using recursion. [5]
Operators and Expression
1.
How do you swap the values of two integers without using the third temporary variable? Justify with the example. [5]
Pointers
1.
List any one advantage and disadvantage of the pointer. How do you pass pointers as function arguments? [5]
Structure and Union
1.
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]
2.
What is the advantage of the union over structure? List any four string library functions with the prototype. [5]