Programming for Problem Solving - B.Tech 2nd Semester Examination, 2025 (Old Course)

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

Programming for Problem Solving

Time: 03 HoursCode: 100204Full 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/answer the following (Any seven question only):[14]
  1. Which of the following cannot be a variable name in C?

    1. volatile
    2. true
    3. friend
    4. export
  2. Which of the following typecasting is accepted by C language

    1. Widening conversions
    2. Narrowing conversions
    3. Widening & Narrowing conversions
    4. None of the mentioned
  3. Which of the following is NOT possible with any 2 operators in C?

    1. Different precedence, same associativity
    2. Different precedence, different associativity
    3. Same precedence, different associativity
    4. All of the mentioned
  4. Functions can return enumeration constants in C?

    1. true
    2. false
    3. depends on the compiler
    4. depends on the standard
  5. C preprocessors can have compiler specific features.

    1. True
    2. False
    3. Depends on the standard
    4. Depends on the platform
  6. How many number of pointer (*) does C have against a pointer variable declaration?

    1. 7
    2. 127
    3. 255
    4. No limits
  7. Which of the following is not possible statically in C language?

    1. Jagged Array
    2. Rectangular Array
    3. Cuboidal Array
    4. Multidimensional Array
  8. What will be the value of the following assignment expression?
    (x = foo())!=1 considering foo() returns 2

    1. 2
    2. True
    3. 1
    4. 0
  9. Comment on the following C statement
    n=1; printf("%d, %d ", 3*n, n++);

    1. Output will be 3, 2
    2. Output will be 3, 1
    3. Output will be 6, 1
    4. Output is compiler dependent
  10. What are the elements present in the array of the following C code?
    int array[5]={5};

    1. 5, 5, 5, 5, 5
    2. 5, 0, 0, 0, 0
    3. 5, NULL, NULL, NULL, NULL
    4. 5
Q.2 Solve both questions :[14]
  1. Explain the major components of a computer system. How does the operating system help in program execution?

  2. Write an algorithm and flowchart to find the largest of three numbers.

Q.3 Solve both questions :[14]
  1. Explain the different arithmetic operators in C. Write the rules for evaluating arithmetic expressions with precedence and associativity.

  2. Write a program to reverse a number using a loop. Explain the concept of an infinite loop with examples. Why do infinite loops occur?

Q.4 Solve both questions :[14]
  1. Explain array declaration and initialization with examples for 1-D and 2-D arrays. Also explain the concept of bound checking.

  2. Write a C program to perform Binary Search on a sorted array.

Q.5 Solve both questions :[14]
  1. What is call by reference? How is passing an array to a function an example of call by reference? Explain with code.

  2. Write a program that reads marks of 5 students into an array and uses a function to compute the average. Demonstrate passing an array to a function.

Q.6 Solve both questions :[14]
  1. Define a structure Student with name, roll, marks. Write a C program to input data for 3 students and print it.

  2. Write a note on accessing structure elements using (a) dot operator, (b) pointer-to-structure. Give examples.

Q.7 Solve both questions :[14]
  1. Explain the concept of pointers in C. How are pointers defined and used? Illustrate with a program that swaps two numbers using pointers.

  2. Write a C program using pointers to reverse an array in-place. Explain how pointers are used in the program.

Q.8 Solve both questions :[14]
  1. Write a recursive C program to find the factorial of a number. Also explain base case and recursive case.

  2. Explain the Ackermann function. Write a recursive program for it. Why is it not suitable for large values?

Q.9 Write short notes on any two of the following:[14]
    • Self-Referential Structures
    • Global and Static Variables
    • Type Casting in C
    • Compiler and Linker