Programming for Problem Solving - B.Tech 2nd Semester Examination, 2025

2025Semester 3Civil-CAEnd Semester
Bihar Engineering University, Patna
B.Tech 2nd Semester Examination, 2025

Programming for Problem Solving

Time: 03 HoursCode: 100203Full 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):[14]
  1. The correct syntax for an if-statement is

    1. if condition() { }
    2. if (condition) {}
    3. if (condition) []
    4. if {condition}
  2. C function execution always begins from

    1. main()
    2. constructor
    3. user-defined function
    4. header file
  3. Which storage class has the default value of a variable as zero?

    1. auto
    2. static
    3. extern
    4. register
  4. Relational operators always return

    1. Float value
    2. 0 or 1
    3. Character
    4. None
  5. Which of the following is an exit-controlled loop?

    1. while loop
    2. for loop
    3. do-while loop
    4. None
  6. Binary search works only on

    1. Unsorted list
    2. Doubly linked list
    3. Sorted list
    4. Any list
  7. break keyword is used to

    1. Restart loop
    2. Terminate loop
    3. Skip iteration
    4. Exit program
  8. In a union, memory allocated is equal to the size of

    1. Sum of all members
    2. Smallest member
    3. Largest member
    4. Twice the size
  9. fopen("abc.txt","r") opens file in

    1. Write mode
    2. Append mode
    3. Read mode
    4. Read + Write mode
  10. Which of the following problems can be solved using recursion?

    1. Fibonacci
    2. Factorial
    3. GCD
    4. All of the above
Q.2 Solve both questions :[14]
  1. Write an algorithm and draw the flowchart for checking whether a number is prime or not.

  2. Differentiate between syntax errors, logical errors, compile-time errors, and run-time errors. Provide suitable examples.

Q.3 Solve both questions :[14]
  1. Explain function declaration, definition, and calling conventions in C. Discuss call by value and call by reference with examples.

  2. Differentiate between while and do-while loop construct. Write a program for generating Fibonacci series using loop.

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

  2. Explain the use of break, continue, and goto statements with examples.

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. What is recursion? Explain how recursion works with stack memory. Write a recursive program for finding the factorial of a number.

Q.6 Solve both questions :[14]
  1. Write a program to perform linear search in an array. Also find its complexity in Best, Average and Worst cases.

  2. Describe the selection sort algorithm and implement it in C language.

Q.7 Solve both questions :[14]
  1. Explain various storage classes in C with proper examples.

  2. Write a program to copy the contents of one file into another and explain each step of file IO.

Q.8 Solve both questions :[14]
  1. Explain arithmetic, relational, logical, bitwise and assignment operators in C along with their precedence rules and examples.

  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]
    • Type Casting
    • Compiler and Interpreter
    • Quick Sort
    • String Functions