Explore topic-wise MCQs in C Programming.

This section includes 204 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.

51.

What will be the output of the program?_x000D_ #include_x000D_ int i;_x000D_ int fun1(int);_x000D_ int fun2(int);_x000D_ _x000D_ int main()_x000D_ {_x000D_ extern int j;_x000D_ int i=3;_x000D_ fun1(i);_x000D_ printf("%d,", i);_x000D_ fun2(i);_x000D_ printf("%d", i);_x000D_ return 0;_x000D_ }_x000D_ int fun1(int j)_x000D_ {_x000D_ printf("%d,", ++j);_x000D_ return 0;_x000D_ }_x000D_ int fun2(int i)_x000D_ {_x000D_ printf("%d,", ++i);_x000D_ return 0;_x000D_ }_x000D_ int j=1;

A. 3, 4, 4, 3
B. 4, 3, 4, 3
C. 3, 3, 4, 4
D. 3, 4, 3, 4
Answer» C. 3, 3, 4, 4
52.

What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ void fun(char*);_x000D_ char a[100];_x000D_ a[0] = 'A'; a[1] = 'B';_x000D_ a[2] = 'C'; a[3] = 'D';_x000D_ fun(&a[0]);_x000D_ return 0;_x000D_ }_x000D_ void fun(char *a)_x000D_ {_x000D_ a++;_x000D_ printf("%c", *a);_x000D_ a++;_x000D_ printf("%c", *a);_x000D_ }

A. AB
B. BC
C. CD
D. No output
Answer» C. CD
53.

What will be the output of the program?_x000D_ #include_x000D_ void fun(int*, int*);_x000D_ int main()_x000D_ {_x000D_ int i=5, j=2;_x000D_ fun(&i, &j);_x000D_ printf("%d, %d", i, j);_x000D_ return 0;_x000D_ }_x000D_ void fun(int *i, int *j)_x000D_ {_x000D_ *i = *i**i;_x000D_ *j = *j**j;_x000D_ }

A. 5, 2
B. 10, 4
C. 2, 5
D. 25, 4
Answer» E.
54.

What will be the output of the program?_x000D_ #include_x000D_ int sumdig(int);_x000D_ int main()_x000D_ {_x000D_ int a, b;_x000D_ a = sumdig(123);_x000D_ b = sumdig(123);_x000D_ printf("%d, %d\n", a, b);_x000D_ return 0;_x000D_ }_x000D_ int sumdig(int n)_x000D_ {_x000D_ int s, d;_x000D_ if(n!=0)_x000D_ {_x000D_ d = n%10;_x000D_ n = n/10;_x000D_ s = d+sumdig(n);_x000D_ }_x000D_ else_x000D_ return 0;_x000D_ return s;_x000D_ }

A. 4, 4
B. 3, 3
C. 6, 6
D. 12, 12
Answer» D. 12, 12
55.

Predict the error, MATLAB will generate, in the following line of code:

A. No error
B. Syntactical error
C. Wrong arguments
D. Expecting (,{ or [View Answer
Answer» B. Syntactical error
56.

Find the error returned by MATLAB:

A. There is no subs command in MATLAB
B. The subs command has syntactical error
C. The subs command has extra input arguments
D. The subs command has incorrect argumentsView Answer
Answer» C. The subs command has extra input arguments
57.

Which line is treated as H1 line?

A. Comment line succeeding function definition
B. Comment line preceding function definition
C. Comment line after function
D. All lines before and after function definition
Answer» D. All lines before and after function definition
58.

How does MATLAB help in passing function arguments?

A. By call by value and call by reference
B. Only by call by value
C. Only by call by reference
D. By call by address
Answer» B. Only by call by value
59.

How do we access a global variable in nested functions?

A. Simply seek the variable from the primary function
B. Make a copy of the global variables from the primary function
C. Declare the variable within the function
D. Declare the variable as global
Answer» E.
60.

Which command can be used for single step execution in debugging mode?

A. dbstep
B. dbstepin
C. dbstatus
D. dbcont
Answer» B. dbstepin
61.

Find the error in below code.

A. There is no function as inline
B. The error will be in defining g
C. The error will be in evaluating a numeric value for the function g
D. Syntactical error in defining gView Answer
Answer» E.
62.

Variables need to have same name while being passed from the primary function to the sub-function.

A. True
B. False
Answer» C.
63.

What are persistent variables?

A. Variables which retain values between calls to the function
B. Variables which help in calling a function
C. Variables which deal with functions
D. Variables global to the function
Answer» B. Variables which help in calling a function
64.

If the program demands evaluation of multiple, only decimal, values of the same function, what is the better way amongst the following?

A. Using anonymous functions or inline functions
B. Using str2func
C. Using private functions
D. Using any function
Answer» C. Using private functions
65.

Which code would you use to find the value of the function f?

A. sin(45)+cos(45)+tan(45)
B. sin(pi/4)+cos(pi/4)+tan(pi/4)
C. sin(45®)+cos(45®)+sin(45®)
D. sind(45)+cosd(45)+tand(45)View Answer
Answer» E.
66.

Predominantly, what are the two kinds of errors in MATLAB programs?

A. Syntax and runtime
B. Syntax and logic
C. Logic and runtime
D. Syntax and algorithmic
Answer» B. Syntax and logic
67.

What is the name of a primary function?

A. Name of M-file
B. Name of Script File
C. Name of Help file
D. Name of Private-File
Answer» B. Name of Script File
68.

The facility that allows nesting one select statement into another is ______________

A. nesting
B. binding
C. subquerying
D. encapsulating
Answer» D. encapsulating
69.

The join in which all the rows from the right table appear in the output irrespective of the content of the other table is ______________

A. CARTESIAN JOIN
B. CROSS JOIN
C. INNER JOIN
D. RIGHT JOIN
Answer» E.
70.

The one that is not optional is _____________

A. select_list
B. table_list
C. row_constraint
D. grouping_columnsView Answer
Answer» B. table_list
71.

What does the AUTO_INCREMENT sequences begin at by default?

A. 0
B. 1
C. -1
D. 2
Answer» C. -1
72.

There cannot be more than one column per table with the AUTO_INCREMENT attribute.

A. True
B. False
Answer» B. False
73.

CGI.pm does not support an object oriented style of use.

A. True
B. False
Answer» C.
74.

The string function that returns the index of the first occurrence of substring is _____________

A. INSERT()
B. INSTR()
C. INSTRING()
D. INFSTR()
Answer» C. INSTRING()
75.

The operator that compares sounds is _____________

A. MATCH SOUNDS
B. CHECK SOUNDS
C. SOUNDS LIKE
D. SOUNDS SIMILAR
Answer» D. SOUNDS SIMILAR
76.

Which function returns NULL if expr1 = expr2?

A. CASE
B. IF()
C. IFNULL()
D. NULLIF()
Answer» E.
77.

The server is told to accept spaces after function names by _____________

A. –sql-mode=SKIP_SPACE
B. –sql-mode=IGNORE_SPACE
C. –sql-mode=SPACE_IGNORE
D. –sql-mode=SPACE_SKIP
Answer» C. –sql-mode=SPACE_IGNORE
78.

Functions are defined using the _________ directive and are stored as R objects.

A. function()
B. funct()
C. functions()
D. fun()
Answer» B. funct()
79.

Which of the following is apply function in R?

A. apply()
B. tapply()
C. fapply()
D. rapply()
Answer» C. fapply()
80.

f(x) = \(\sqrt{9-x^2}\). Find the range of the function.

A. R
B. R+
C. [-3,3]
D. [0,3]
Answer» E.
81.

f(x) = \(\sqrt{9-x^2}\). Find the domain of the function.

A. (0,3)
B. [0,3]
C. [-3,3]
D. (-3,3)
Answer» D. (-3,3)
82.

Find range of function |x|.

A. Set of real numbers
B. Set of positive real numbers
C. Set of integers
D. Set of natural numbers
Answer» C. Set of integers
83.

Find domain of function |x|.

A. Set of real numbers
B. Set of positive real numbers
C. Set of integers
D. Set of natural numbers
Answer» B. Set of positive real numbers
84.

f(x) = {\(\frac{|x|}{x}\) for x≠0 and 0 for x=0}. Which function is this?

A. Constant
B. Modulus
C. Identity
D. Signum function
Answer» E.
85.

Which function is shown in graph?

A. Constant
B. Modulus
C. Identity
D. Signum function
Answer» D. Signum function
86.

Which of the following is not a function?

A. {(1,2), (2,4), (3,6)}
B. {(-1,1), (-2,4), (2,4)}
C. {(1,2), (1,4), (2,5), (3,8)}
D. {(1,1), (2,2), (3,3)}
Answer» D. {(1,1), (2,2), (3,3)}
87.

Let R be a relation defined on set of natural numbers {(x, y): y=2x}. Is this relation can be called a function?

A. True
B. False
Answer» B. False
88.

In a function from set A to set B, image can have more than one preimage.

A. True
B. False
Answer» B. False
89.

In a function from set A to set B, every element of set A has___________ image in set B.

A. one and only one
B. different
C. same
D. many
Answer» B. different
90.

Which of the following is important in a function?

A. Return type
B. Function name
C. Both return type and function name
D. The return type, function name and parameter list
Answer» D. The return type, function name and parameter list
91.

From which function the execution of a C++ program starts?

A. start() function
B. main() function
C. new() function
D. end() function
Answer» C. new() function
92.

Which of the following feature is used in function overloading and function with default argument?

A. Encapsulation
B. Polymorphism
C. Abstraction
D. Modularity
Answer» C. Abstraction
93.

If an argument from the parameter list of a function is defined constant then _______________

A. It can be modified inside the function
B. It cannot be modified inside the function
C. Error occurs
D. Segmentation fault
Answer» C. Error occurs
94.

Where should default parameters appear in a function prototype?

A. To the rightmost side of the parameter list
B. To the leftmost side of the parameter list
C. Anywhere inside the parameter list
D. Middle of the parameter list
Answer» B. To the leftmost side of the parameter list
95.

When we define the default values for a function?

A. When a function is defined
B. When a function is declared
C. When the scope of the function is over
D. When a function is called
Answer» C. When the scope of the function is over
96.

In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursive

A. i, iv
B. iii, iv
C. ii, iii, iv
D. i, iii, iv
Answer» E.
97.

An inline function is expanded during ______________

A. compile-time
B. run-time
C. never expanded
D. end of the program
Answer» B. run-time
98.

What is an inline function?

A. A function that is expanded at each call during execution
B. A function that is called during compile time
C. A function that is not checked for syntax errors
D. A function that is not checked for semantic analysis
Answer» B. A function that is called during compile time
99.

What happens to a function defined inside a class without any complex operations (like looping, a large number of lines, etc)?

A. It becomes a virtual function of the class
B. It becomes a default calling function of the class
C. ?a) It becomes a virtual function of the classb) It becomes a default calling function of the classc) It becomes an inline function of the class
D. The program gives an error
Answer» D. The program gives an error
100.

Which of the following is the default return value of functions in C++?

A. int
B. char
C. float
D. void
Answer» B. char