Programming for Problem Solving - B.Tech 2nd Semester Exam., 2019 (New Course)

2019Semester 3Civil-CAEnd Semester
Bihar Engineering University, Patna
B.Tech 2nd Semester Exam., 2019 (New Course)

Programming for Problem Solving

Time: 3 hours Code: 100204 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 alternative (any seven): [2x7=14]
  1. What will be the data type of result of the following operation?
    (float)a * (int)b/(long)c * (double)d)

    1. int
    2. long
    3. float
    4. double
  2. What does the following declaration mean?
    int (*ptr) [10];

    1. ptr is array of pointers to 10 integers
    2. ptr is a pointer to an array of 10 integers
    3. ptr is an array of 10 integers
    4. ptr is a pointer to array
  3. Which of the following is a correct format for declaration of function?

    1. return-type function-name (argument type);
    2. return-type function-name (argument type) {}
    3. return-type (argument type) function-name;
    4. All of the above
  4. The value obtained in the function is given back to main by using ______ keyword.

    1. return
    2. static
    3. new
    4. volatile
  5. Which data type is most suitable for storing a number 65000 in a 32-bit system?

    1. signed short
    2. unsigned short
    3. long
    4. int
  6. Which of the following declarations is not supported by C?

    1. String str;
    2. Char *str;
    3. Float str = 3e2;
    4. None of the above
  7. Which of the following is an invalid if-else statement?

    1. if (if (i == 1)) {}
    2. if (func1 (a)) {}
    3. if (a) {}
    4. if ((char) a) {}
  8. A local variable declaration with no storage class specified is by default

    1. auto
    2. extern
    3. static
    4. register
  9. Automatic variables are initialized to

    1. zero
    2. junk value
    3. None of the above
    4. Both (i) and (ii)
  10. The getchar() function is defined in ______ header file.

    1. conio.h
    2. stdio.h
    3. iostream.h
    4. None of the above
Q.2 Solve all parts : [14]
  1. What do you understand by the term 'problem solving'? How can programming be used to do problem solving?

  2. Discuss about the components of computer system. How are they involved in computer programming activity?

  3. Write the algorithm for exchanging the values of two variables.

Q.3 Solve all parts : [14]
  1. Differentiate between flowchart, pseudo-code and source code.

  2. What are the outcomes of compilation of a program? Discuss in detail.

  3. What are constants? List the types of constants as defined in C language.

Q.4 Solve all parts : [14]
  1. What are the libraries? How are they different from header files?

  2. What is an array? Write a C program to find the average of 10 numbers of an array.

  3. What do you understand by the operator precedence? Explain.

Q.5 Solve both questions : [14]
  1. Define storage classes of C with some appropriate examples.

  2. What is branching? What are the possible types of branching and the C statements used for such type of branching? Give a detailed explanation with example.

Q.6 Solve both questions : [14]
  1. Write a C program to calculate 12!/8. The operation is factorial of 12, divided by 8. Also comment by examine whether the algorithm used is efficient.

  2. What is type casting? Explain its classification through examples.

Q.7 Solve all parts : [14]
  1. Give the purpose, proper syntax and other variants of 'getch()' and 'gets()' functions.

  2. How can an array of numbers be passed to function as parameter? Write an example C program in support.

  3. What is dynamic memory allocation in C?

Q.8 Solve both questions : [14]
  1. Differentiate between the following:
    (i) Structures and Union
    (ii) Formatted and Unformatted data files

  2. What is a file? List different operations performed on file. How are they achieved? Explain.

Q.9 Solve all parts : [14]
  1. Write a C program to create an array of structures named "STUDENT" with fields, Name, Cell no, Address, and Marks. How to show any student record using this structure?

  2. Which of the sorting algorithm is better than other and why? Explain.

  3. Write C program for merge sort algorithm.