Programming for Problem Solving - B.Tech 1st Semester Examination, 2024 (Old)

2024Semester 2Civil-CAEnd Semester
Bihar Engineering University, Patna
B.Tech 1st Semester Examination, 2024 (Old)

Programming for Problem Solving

Time: 03 HoursCode: 100104Full Marks: 70

Instructions:

  1. The marks are indicated in the right-hand margin.
  2. There are NINE questions in this paper.
  3. Attempt FIVE questions in all.
  4. Question No. 1 is compulsory.
Q.1 Choose the correct option for the following questions (Answer any seven only):[14]
  1. Where is a program stored and executed?

    1. Hard Disk
    2. Main Memory (RAM)
    3. Cache
    4. ROM
  2. What is the output of a compiler?

    1. Source code
    2. Flowchart
    3. Executable code
    4. Algorithm
  3. Which storage class has the default value of a variable as zero?

    1. auto
    2. extern
    3. static
    4. register
  4. What is the result of 5% 2 in C?

    1. 2.5
    2. 1
    3. 2
    4. 0
  5. What type of array is used to store string?

    1. int
    2. float
    3. char
    4. double
  6. Binary search works only on:

    1. Unsorted list
    2. Doubly linked list
    3. Sorted list
    4. Any list
  7. Which operator is used to access members of a structure using a pointer?

    1. .
    2. ->
    3. *
    4. &
  8. What is the output of \( *(\&x) \) in C?

    1. Address of x
    2. Error
    3. Value of x
    4. Nothing
  9. Which function is used to open a file in C?

    1. fopen()
    2. file()
    3. openfile()
    4. fcreate()
  10. Which of the following problems can be solved using recursion?

    1. Fibonacci
    2. GCD
    3. Factorial
    4. All of the above
Q.2 Solve both questions :[14]
  1. Draw a flowchart to find the largest of three numbers.

  2. Explain different storage classes in C.

Q.3 Solve both questions :[14]
  1. What is type casting in programming? Differentiate between implicit and explicit type conversion with examples.

  2. Explain operator precedence and associativity with examples.

Q.4 Solve both questions :[14]
  1. Write the differences between if, if-else, and switch statements with examples.

  2. Explain the concept of pointer to pointer with a code example. What is a self-referential structure?

Q.5 Solve both questions :[14]
  1. How are arrays declared and initialized in C? What is bound checking? Why is it important in array programming?

  2. Explain the different modes of opening a file in C. Give examples.

Q.6 Solve both questions :[14]
  1. Write a program to perform linear search in an array.

  2. Describe the bubble sort algorithm and write its implementation in C.

Q.7 Solve both questions :[14]
  1. What is the difference between call by value and call by reference? Explain with examples.

  2. What is the scope of a variable? Explain local and global scope with examples.

Q.8 Solve both questions :[14]
  1. What is recursion? Write a recursive function to compute the nth Fibonacci number.

  2. What is the difference between structure and union? Explain with an example.

Q.9 Write Short notes on any two of the following:[14]
  1. Self-Referential Structure

  2. Compiler and Linker

  3. Syntax and logical errors

  4. Bitwise Operator