Bsc Csit Nepal

2079

C Programming

Full Marks: 60
Pass Marks: 24
Time: 3 hours

Attempt any two questions: (2 x 10 = 20)

  1. What is the difference between exit(0) and exit(1)? Discuss the need of nested structure with and example. Write a program to find the val;ue of x^y awithout using POW function. [2+3+5]

  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. [2+3+5]

    int main()
    {
       int a,b,c
       scanf("%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;
    }
  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. [10]

Attempt any eight questions: (8 x 5 = 40)

  1. How do you swap the values of two integers without using the third temporary variable? Justify with example. [5]
  2. Write a program to find the sum of digits of a given integer using recursion. [5]
  3. Differentiate between constant and literals. Why do we need to define the types of data? [3+2]
  4. Write a program to find the second largest number in the given array of numbers. [5]
  5. Create a structure “Employee” having Name, Address, Salary, Age as member function. Display the name of employee having age between 40 and 50 and are living in Kathmandu. [5]
  6. List any one advanyage and disadvantage of pointer. How do you pass pointers as arguments in function? [2+3]
  7. Suppose a file names “Num.txt” contains a list in integers. Write a program to extract the prime nummbers only from that file and write them on “Prime.txt” file. [5]
  8. What is the advantage of union over structure? List any four string library function with prototype. [1+4]
  9. Write short notes on:[2x2.5=5]
    • a. Local, Global and Static variables
    • b. Conditional operator