Explore topic-wise MCQs in Testing Subject.

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

1.

What is the output of this C code? double foo(); int main() { foo(); return 0; } foo() { printf("2 "); return 2; }

A. 2
B. Compile time error
C. Depends on the compiler
D.
Answer» C. Depends on the compiler
2.

What is the output of this C code? int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }

A. 2
B. Compile time error
C. Depends on the compiler
D. Depends on the standard
Answer» B. Compile time error
3.

functions can return structure in c?

A. true
B. false
C. Depends on the compiler
D. Depends on the standard
Answer» B. false
4.

What is the default return type if it is not specified in function definition?

A. void
B. int
C. double
D. short int
Answer» C. double
5.

The output of the code below is int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }

A. 5
B. 8
C. Nothing
D. Varies
Answer» E.
6.

The output of the code below is void m(int k) { printf("hi"); } void m(double k) { printf("hello"); } void main() { m(3); }

A. hi
B. hello
C. Compile time error
D. Nothing
Answer» D. Nothing
7.

The output of the code below is int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; }

A. hello 5 8
B. hello 5
C. hello followed by garbage value
D. Compilation error
Answer» D. Compilation error
8.

The output of the code below is int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }

A. 5
B. 7
C. Junk value
Answer» B. 7
9.

The output of the code below is void main() { int k = m(); printf("%d", k); } void m() { printf("hello"); }

A. hello 5
B. Error
C. Nothing
D. Junk value
Answer» B. Error
10.

What will be the data type returned for the following function? int func() { return (double)(char)5.0; }

A. char
B. int
C. double
D. multiple type-casting in return is illegal
Answer» C. double
11.

What is the problem in the following declarations? int func(int); double func(int); int func(float);

A. A function with same name cannot have different signatures
B. A function with same name cannot have different return types
C. A function with same name cannot have different number of parameters
D. All of the mentioned
Answer» E.
12.

What is the output of this code having void return-type function? void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }

A. 1
B. Runtime error
C. Compile time error
Answer» E.
13.

The value obtained in the function is given back to main by using ________ keyword?

A. return
B. static
C. new
D. volatile
Answer» B. static
14.

What is the return-type of the function sqrt()

A. int
B. float
C. double
D. Depends on the data type of the parameter
Answer» D. Depends on the data type of the parameter
15.

Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]

A. Yes, and we can use the function value conveniently
B. Yes, but we call the function again to get the value, not as convenient as in using variable
C.
D. D.
Answer» D. D.
16.

Which of the following is a correct format for declaration of function?

A. return-type function-name(argument type);
B. return-type function-name(argument type) {}
C. return-type (argument type)function-name
D. Both (a) and (b)
Answer» B. return-type function-name(argument type) {}
17.

Which of the following function declaration is illegal?

A. int 1bhk(int);
B. int 1bhk(int a);
C. int 2bhk(int*, int []);
D. All of the mentioned
Answer» E.
18.

What is the output of this C code? void main() { m(); void m() { printf("hi"); } }

A. hi
B. Compile time error
C. Nothing
D. Varies
Answer» C. Nothing
19.

What is the output of this C code? void m() { printf("hi"); } void main() { m(); }

A. hi
B. Run time error
C. Nothing
D. Varies
Answer» B. Run time error
20.

What is the output of this C code? void foo(); int main() { void foo(int); foo(); return 0; } void foo() { printf("2 "); }

A. 2
B. Compile time error
C. Depends on the compiler
D. Depends on the standard
Answer» C. Depends on the compiler
21.

What is the output of this C code? void m(); void n() { m(); } void main() { void m() { printf("hi"); } }

A. hi
B. Compile time error
C. Nothing
D. Varies
Answer» C. Nothing
22.

What is the output of this C code? void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }

A. 2
B. Compile time error
C. Depends on the compiler
D. Depends on the standard
Answer» B. Compile time error
23.

What is the output of this C code? void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }

A. Compile time error
B. 2
C. Depends on the compiler
D. Depends on the standard
Answer» C. Depends on the compiler
24.

What is the output of this C code? int main() { void foo(); void f() { foo(); } f(); } void foo() { printf("2 "); }

A. 2 2
B. 2
C. Compile time error
D. Depends on the compiler
Answer» E.
25.

What is the output of this C code? int main() { void foo(), f(); f(); } void foo() { printf("2 "); } void f() { printf("1 "); foo(); }

A. Compile time error as foo is local to main
B. 1 2
C. 2 1
D. Compile time error due to declaration of functions inside main
Answer» C. 2 1
26.

In a function two return statements should never occur.

A. Yes
B. No
Answer» C.
27.

If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?

A.
B. B.
Answer» B. B.
28.

In C all functions except main() can be called recursively.

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

Use of functions

A. Helps to avoid repeating a set of statements many times.
B. Enhances the logical clarity of the program.
C. Helps to avoid repeated programming across programs.
D. Makes the debugging task easier.
E. All of the above
Answer» F.
30.

What will happen after compiling and running following code? main() { printf("%p", main); }

A. Error
B. Will make an infinite loop.
C. Some address will be printed.
D. None of these.
Answer» D. None of these.
31.

What is the output of the below code snippet? #include main() { unsigned x = 5, y=&x, *p = y+0; printf("%u",*p); }

A. Address of x
B. Address of y
C. Address of p
D. 5
Answer» E.
32.

What is the notation for the following functions? 1. int f(int a, float b) { /* Some code */ } 2. int f(a, b) int a; float b; { /* Some code */ }

A. 1. KR Notation 2. ANSI Notation
B. 1. Pre ANSI C Notation 2. KR Notation
C. 1. ANSI Notation 2. KR Notation
D. 1. ANSI Notation 2. Pre ANSI Notation
Answer» D. 1. ANSI Notation 2. Pre ANSI Notation
33.

What is the output of the following program? #include void swap(int m, int n) { int x = m; m = n; n = x; } main() { int x=5, y=3; swap(x,y); printf("%d %d", x, y); }

A. 3 5
B. 5 3
C. 5 5
D. Compile error
Answer» C. 5 5
34.

Which variable has the longest scope? int b; int main() { int c; return 0; } int a;

A. a
B. b
C. c
D. Both (a) and (b)
Answer» C. c