CU SEC-A-1 C Programming Language, 2019

University of Calcutta question paper, B.Sc. Honours Semester III, 2019. C Programming Language. Typed in LaTeX, searchable, with a printable PDF.

Open this paper in MathQP

  1. Which one of the following is invalid real constant?
  2. Which one of the following is invalid variable name?
  3. What is the output of the following C program? #include <stdio.h> main() int a = 10/3; printf("
  4. What is the output of the following program? void main () int x = 3, y = 0; if (x != y) printf("Not Equal"); else printf("Equal");
  5. C programs are converted into machine language with the help of
  6. What is the only function that all C programs must contain?
  7. What will be the output of the program? #include <stdio.h> #include <stdlib.h> main() int i = -3, j = 2, k = 0, m; m = ++i ++j ++k; printf("
  8. To print out values of texttt a and texttt b given below, which of the following texttt printf() statement will you use? #include <stdio.h> float a = 3.14; double b = 3.14;
  9. How many times will “STOP” be printed in the following program? #include <stdio.h> int main() int n; for (n = 1; n <= 10; n++) printf("STOP");
  10. The Keyword used to transfer control from a function back to the calling function is
  11. What is a programming language? Write short notes on High Level Language and Low Level Language.
  12. What is Operating system? Give example. State two functions of operating system.
  13. Write short notes on Compiler, Interpreter and Assembler.
  14. What is meant by an operator in C? Between Arithmetic operator and Relational operator which has the higher priority?
  15. Write down the output of the following C program : #include <stdio.h> main() int i = 5; int j = i / -4; int k = i printf("
  16. Write down the while- and do- statement which are equivalent to the following for- statement : for (n = 1; n <= 10; ++n) ........ ........
  17. State the main distinction between library functions and user-defined functions in C.
  18. Using suitable header file(s), write a C program to find the square root of a given real number, where the number is read from the terminal.
  19. State the general form of switch and break statements. Explain their functions.
  20. How long does the following loop run? for (x = 9; x < 9; x = x - 1) printf(" Justify your answer.
  21. Find if there is any error(s) in the following C code : #include <stdio.h> void main () int i = 0; for (i = 0; i < 5; i++) if (i < 4); printf("Hello"); break; If any error is found rectify the program and write down the output of the rectified program.
  22. What is a one-dimensional array? Explain with an example.
  23. Use a for loop to initialize 200 elements of an array, say, texttt sum , without a repeat count, such that the first 100 elements are initialized to zero ( 0 ) and the remaining 100 elements are initialized to 1.0 .
  24. Consider the following arrangement of elements : 31 28 36 21 19 32 40 23 24 Represent the elements of the above arrangement with two-dimensional array, where the first index selects the row and the second index selects the column within that row. Remember that each dimension of the array is indexed from zero to its maximum size minus one.
  25. Describe the functions which are defined in the following header files : texttt <stdio.h> , texttt <math.h> , texttt <stdlib.h> , texttt <string.h> and texttt <time.h>
  26. texttt return;
  27. texttt return (expression);
  28. Can a function have more than one return statement? Explain with an example.
  29. Write an algorithm to find H.C.F. and L.C.M. of two distinct positive integers ‘ m ' and ‘ n '.
  30. Draw a flowchart to print the first 20 terms of the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, ldots
  31. Write a C program to find the perimeter and area of a triangle having sides of length x 1, x 2, x 3 .
  32. If x 1 = 3.0, x 2 = 4.0, x 3 = 5.0 , then write the C program for writing the output in the file “Triangle.out”.
  33. Draw a flowchart and write the C program to calculate the value of sin (x) from its power series expansion (considering first five terms).
  34. Write a C program to separate even and odd integers in a given range. Write the output in file.
  35. Draw a flowchart to print the factors of the integer 215 and find sum of the factors.
  36. Explain nested if-else with suitable example. What is the difference between nested if-else and switch case?
  37. What is an algorithm? What are the properties that an algorithm should have?
  38. Write an algorithm to find all roots (real / complex) of a quadratic equation ax 2 + bx + c = 0 . Also construct the corresponding flowchart.
  39. The value of the arithmetic expression texttt 5*3/4 - 3/4*5 (written in C++) is
  40. The major goal of inheritance in C++ is to
  41. Consider the class definitions : class Maths Student std1; ; class Student String name; ; These code represents
  42. An exception is caused by a
  43. Which of the following statements are true in C++?
  44. To be called object-oriented, a programming language must allow
  45. An array name is a
  46. Which keyword is used to access the variable in namespace?
  47. A function that is called automatically each time an object is destroyed is a
  48. The generic type in a template function
  49. Write an efficient program in C++ to print the first n non-Fibonacci positive integers starting from 4 .
  50. Write an efficient program in C++ to find the number of prime numbers between m and m+n ( m and n are given positive integers).
  51. What is object-oriented programming? What are the main characteristics of the object-oriented programming languages?
  52. Discuss the unique advantages of an object-oriented programming paradigm.
  53. Why do we need the preprocessor directive texttt #include (iostream) ? How does a texttt main() function in C++ differ from texttt main() in C?
  54. texttt ctype.h and texttt string.h
  55. Array and Pointers
  56. Write a C++ program that will ask for a temperature in Fahrenheit and display it in Celsius.
  57. Identify the error in the following program : 3+2 #include (iostream.h) void main() int i = 0; i = i + 1; cout << i << " "; /*comment *//i = i + 1; cout << i;
  58. What is a friend function? Mention some characteristics of a friend function.
  59. What is containership in C++? How does it differ from inheritance?
  60. What is constructor? Is it mandatory to use constructors in a class in C++? Discuss.
  61. Discuss briefly the importance of operator overloading through an example. How can we overload texttt ++ operator in C++?
  62. What is a class? How does it accomplish data hiding?
  63. What are objects? How are they created?
  64. What does inheritance mean in C++? Is there any difference between private and protected inheritance? Explain with suitable example.
  65. What is polymorphism? Explain virtual function with example.
  66. What is copy constructor? When is copy constructor called? Can we make copy constructor private?
  67. Write a C++ program to sort 100 numbers in ascending order.
  68. Write a C++ program to find the binary representation of a given decimal number.
  69. Write a C++ program to multiply two given 4 times 4 matrices.
  70. Discuss a template class in C++ with an example.
  71. What are the advantages of exception handling over traditional error handling?
  72. Explain with suitable example how a function call texttt operator() can be overloaded. Why subscript operator is overloaded?