Tribhuvan University

Institute of Science and Technology

TU Exam Year: 2079

Bachelor Level: B.Sc. CSIT

Semester: First

Subject: C Programming (CSC115)

Full Marks: 60 | Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as far as practicable.

SECTION A

Attempt all questions.

  1. 1.
    What is the difference between exit(0) 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 function.
  2. 2.

    Why do we need break and continue statement? Define formal argument and actual argument in function with example. Identify and list the errors in following code:
    Find Error

    "
  3. 3.
    Write a program to demonstrate the following menu driven program. The user will provide an integer and an alphabet for making a choice and corresponding task has to be performed accordingly as follows:

    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 give "D" as choice.
  4. 4.
    How do you swap the values of two integers without using the third temporary variable? Justify with the example.
  5. 5.
    Write a program to find the sum of digits of a given integer using recursion.
  6. 6.
    Differentiate between constant and literals. Why do we need to define the types of data?
  7. 7.
    Write a program to find the second largest number in the given array of numbers.
  8. 8.
    Create a structure "Employee" having Name, Address, Salary, Age as member functions. Display the name of employee having age between 40 and 50 and are living in Kathmandu.
  9. 9.
    List any one advantage and disadvantage of pointer. How do you pass pointers as function arguments?
  10. 10.
    Suppose a file named "Num.txt" contains a list in integers. Write a program to extract the prime numbers only from that file and write them on "Prime.txt" file.
  11. 11.
    What is the advantage of union over structure? List any four string library functions with prototype.
  12. 12.
    Write short notes on:
    a. Local, Global and Static variables
    b. Conditional operator