Programming for Problem Solving - B.Tech 1st Semester Exam-2022

2022Semester 2Civil-CAEnd Semester
Bihar Engineering University, Patna
B.Tech 1st Semester Exam-2022

Programming for Problem Solving

Time: 03 Hours Code: 100104 Full 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 answer of the following (any seven): [14]
  1. What does the following declaration mean?
    int *ptr [5];

    1. ptr is an array of pointers to 5 integers
    2. ptr is an array of 5 integers
    3. ptr is a pointer to an array of 5 integers
    4. ptr is a pointer to array
  2. The function malloc() is declared in which header file.

    1. stdio.h
    2. stdlib.h
    3. conio.h
    4. iostream.h
  3. What is the output of:
    #include<stdio.h>
    int main()
    {
      char ch = 'Z';
      printf("%d ", ch);
      return 0;
    }

    1. 65
    2. 90
    3. 97
    4. 122
  4. How is an array initialized in C language?

    1. int a[3] = {1, 2, 3};
    2. int a = {1, 2, 3};
    3. int a [ ] = new int[3];
    4. int a(3) = {1, 2, 3};
  5. What is the return type of the fopen() function in C?

    1. Pointer to a FILE object.
    2. Pointer to an integer.
    3. An integer.
    4. None of the above.
  6. What will be the output of the following C Code?
    #include<stdio.h>
    int main()
    {
      int x=4, y, z;
      y=--x;
      z=x--;
      printf("%d%d%d", x, y, z);
    }

    1. 3 2 3
    2. 2 2 3
    3. 3 2 2
    4. 2 3 3
  7. The keyword used to transfer control from a function back to the calling function is.

    1. switch
    2. return
    3. continue
    4. go to
  8. What is the output of:
    #include <stdio.h>
    int main( )
    {
      float a = 5, b = 2;
      int c,d;
      c = a/b;
      d = c/2;
      printf("%d", d);
      return 0;
    }

    1. 1
    2. 0
    3. 1.5
    4. 1.25
  9. In C, if you pass an array as an argument to a function, what actually gets passed?

    1. First element of the array
    2. Value of elements of the array
    3. Base address of the array
    4. Address of the last element of array
  10. How is the \(3^{rd}\) element in an array accessed based on pointer notation?

    1. *a+3
    2. *(a+3)
    3. *(*a+3)
    4. &(a+3)
Q.2 Solve both questions : [7+7=14]
  1. Explain entry controlled loop and exit controlled loop with flow charts and examples.

  2. Write a C program to reverse a given multi-digit number.

Q.3 Solve both questions : [7+7=14]
  1. Explain break and continue keywords with suitable examples in context of managing loops.

  2. What is storage classes in C. Write features (storage, default value, scope, life) of variables defined under each storage class.

Q.4 Solve both questions : [7+7=14]
  1. Write a C function for Bubble sort. Analyse the time complexity of Bubble sort for each standard cases.

  2. Differentiate between formal argument and actual argument with an example.

Q.5 Solve both questions : [7+7=14]
  1. What is recursion? Write a recursive C program to generate \(n^{th}\) term of the Fibonacci series.

  2. How string is declared and initialized? Explain any four predefined string manipulation functions with examples.

Q.6 Solve both questions : [7+7=14]
  1. Write a C program to find result matrix after multiplying two given matrices using 2-D arrays.

  2. Write a program to copy contents of one file to another. While doing so replace all lowercase characters to their equivalent uppercase characters.

Q.7 Solve both questions : [7+7=14]
  1. Write the difference between structure and union. Compare them with the help of an example.

  2. Write a program to copy the contents of one array into another in reverse order.

Q.8 Solve both questions : [7+7=14]
  1. Differentiate between call-by-value and call-by-reference with suitable examples.

  2. Discuss conditional operator? Write a C program to find largest of three numbers using conditional operator?

Q.9 Solve both questions : [7+7=14]
  1. Write a C program that converts a string like "124" to an integer 124.

  2. Write a C program using the nesting of loops to print the following pattern:
          1
        2  3
      4  5  6
    7  8  9  10