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.

Every C program will contain at least one preprocessor directive.

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

Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation.

A. True
B. False
Answer» B. False
3.

What will be the output of the program (sample.c) given below if it is executed from the command line? cmd> sample Jan Feb Mar /* sample.c */ #include<stdio.h> #include<dos.h> int main(int arc, char *arv[]) { int i; for(i=1; i<_argc; i++) printf("%s ", _argv[i]); return 0; }

A. No output
B. sample Jan Feb Mar
C. Jan Feb Mar
D. Error
Answer» D. Error
4.

Macros with arguments are allowed

A. True
B. False
Answer» B. False
5.

Which of the following statements correctly assigns 12 to month using pointer variable pdt? #include<stdio.h> struct date { int day; int month; int year; }; int main() { struct date d; struct date *pdt; pdt = &d; return 0; }

A. pdt.month = 12
B. &pdt.month = 12
C. d.month = 12
D. pdt->month = 12
Answer» E.
6.

A union cannot be nested in a structure

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

Bit fields CANNOT be used in union.

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

one of elements of a structure can be a pointer to the same structure.

A. True
B. False
Answer» B. False
9.

A structure can be nested inside another structure.

A. True
B. False
Answer» B. False
10.

Point out the error in the program? typedef struct data mystruct; struct data { int x; mystruct *b; };

A. Error: in structure declaration
B. Linker Error
C. No Error
D. None of above
Answer» D. None of above
11.

Point out the error in the program? #include<stdio.h> int main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0; i<=9; i++) scanf("%s %f", e[i].name, &e[i].sal); return 0; }

A. Error: invalid structure member
B. Error: Floating point formats not linked
C. No error
D. None of above
Answer» C. No error
12.

What will be the output of the program ? #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u; u.ch[0]=3; u.ch[1]=2; printf("%d, %d, %d n", u.ch[0], u.ch[1], u.i); return 0; }

A. 3, 2, 515
B. 515, 2, 3
C. 3, 2, 5
D. 515, 515, 4
Answer» B. 515, 2, 3
13.

What will be the output of the program ? #include<stdio.h> int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1, 2, 13}; printf("%d, %d, %d n", bit.bit1, bit.bit3, bit.bit4); return 0; }

A. 1, 2, 13
B. 1, 4, 4
C. -1, 2, -3
D. -1, -2, -13
Answer» D. -1, -2, -13
14.

What will be the output of the program ? #include<stdio.h> int main() { enum days {MON=-1, TUE, WED=6, THU, FRI, SAT}; printf("%d, %d, %d, %d, %d, %d n", MON, TUE, WED, THU, FRI, SAT); return 0; }

A. -1, 0, 1, 2, 3, 4
B. -1, 2, 6, 3, 4, 5
C. -1, 0, 6, 2, 3, 4
D. -1, 0, 6, 7, 8, 9
Answer» E.
15.

What will be the output of the program in 16 bit platform (Turbo C under DOS) ? #include<stdio.h> int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit; printf("%d n", sizeof(bit)); return 0; }

A. 1
B. 2
C. 4
D. 9
Answer» C. 4
16.

What will be the output of the program (myprog.c) given below if it is executed from the command line? cmd> myprog one two three /* myprog.c */ #include<stdio.h> int main(int argc, char **argv) { printf("%c n", **++argv); return 0; }

A. myprog one two three
B. myprog one
C. o
D. two
Answer» D. two
17.

What will be the output of the program (myprog.c) given below if it is executed from the command line? cmd> myprog one two three /* myprog.c */ #include<stdio.h> #include<stdlib.h> int main(int argc, char **argv) { printf("%s n", *++argv); return 0; }

A. myprog
B. one
C. two
D. three
Answer» C. two
18.

What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)? cmd> sample Good Morning /* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%d %s", argc, argv[1]); return 0; }

A. 3 Good
B. 2 Good
C. Good Morning
D. 3 Morning
Answer» B. 2 Good
19.

What will be the output of the program #include<stdio.h> void fun(int); int main(int argc) { printf("%d ", argc); fun(argc); return 0; } void fun(int i) { if(i!=4) main(++i); }

A. 1 2 3
B. 1 2 3 4
C. 2 3 4
D. 1
Answer» C. 2 3 4
20.

What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { int i, n; char *x="Alice"; n = strlen(x); *x = x[n]; for(i=0; i<=n; i++) { printf("%s ", x); x++; } printf(" n", x); return 0; }

A. Alice
B. ecilA
C. Alice lice ice ce e
D. lice ice ce e
Answer» E.
21.

Macro calls and function calls work exactly similarly.

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

Every time we supply new set of values to the program at command prompt, we need to recompile the program.

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

If the size of integer is 4bytes, What will be the output of the program? #include<stdio.h> int main() { int arr[] = {12, 13, 14, 15, 16}; printf("%d, %d, %d n", sizeof(arr), sizeof(*arr), sizeof(arr[0])); return 0; }

A. 10, 2, 4
B. 20, 4, 4
C. 16, 2, 2
D. 20, 2, 2
Answer» C. 16, 2, 2
24.

What will be the output of the program? #include<stdio.h> #define SWAP(a, b) int t; t=a, a=b, b=t; int main() { int a=10, b=12; SWAP(a, b); printf("a = %d, b = %d n", a, b); return 0; }

A. a = 10, b = 12
B. a = 12, b = 10
C. Error: Declaration not allowed in macro
D. Error: Undefined symbol 't'
Answer» C. Error: Declaration not allowed in macro
25.

What will be the output of the program? #include<stdio.h> #define PRINT(int) printf("int=%d, ", int); int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; }

A. int=2, int=3, int=4
B. int=2, int=2, int=2
C. int=3, int=3, int=3
D. int=4, int=4, int=4
Answer» B. int=2, int=2, int=2
26.

What will be the output of the program? #include<stdio.h> #define FUN(i, j) i##j int main() { int va1=10; int va12=20; printf("%d n", FUN(va1, 2)); return 0; }

A. 10
B. 20
C. 1020
D. 12
Answer» C. 1020
27.

What will be the output of the program? #include<stdio.h> #define MAX(a, b) (a > b ? a : b) int main() { int x; x = MAX(3+2, 2+7); printf("%d n", x); return 0; }

A. 8
B. 9
C. 6
D. 5
Answer» C. 6
28.

What will be the output of the program ? #include<stdio.h> int main() { char str1[] = "India"; char str2[] = "BIX"; char *s1 = str1, *s2=str2; while(*s1++ = *s2++) printf("%s", str1); printf(" n"); return 0; }

A. IndiaBIX
B. BndiaBIdiaBIXia
C. India
D. (null)
Answer» C. India
29.

What will be the output of the program assuming that the array begins at location 1002? #include<stdio.h> int main() { int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} }; printf("%u, %u, %u, %d n", a, *a, **a, ***a); return 0; }

A. 1002, 2004, 4008, 2
B. 2004, 4008, 8016, 1
C. 1002, 1002, 1002, 1
D. Error
Answer» D. Error
30.

What will be the output of the program ? #include<stdio.h> int main() { char str[] = "peace"; char *s = str; printf("%s n", s++ +3); return 0; }

A. peace
B. eace
C. ace
D. ce
Answer» E.
31.

What will be the output of the program ? #include<stdio.h> power(int**); int main() { int a=5, *aa; /* Address of 'a' is 1000 */ aa = &a; a = power(&aa); printf("%d n", a); return 0; } power(int **ptr) { int b; b = **ptr***ptr; return (b); }

A. 5
B. 25
C. 125
D. Garbage value
Answer» C. 125
32.

What will be the output of the program ? #include<stdio.h> int main() { printf("%c n", 7["IndiaBIX"]); return 0; }

A. Error: in printf
B. Nothing will print
C. print "X" of IndiaBIX
D. print "7"
Answer» D. print "7"
33.

What will be the output of the program ? #include<stdio.h> int *check(static int, static int); int main() { int *c; c = check(10, 20); printf("%d n", c); return 0; } int *check(static int i, static int j) { int *p, *q; p = &i; q = &j; if(i >= 45) return (p); else return (q); }

A. 10
B. 20
C. Error: Non portable pointer conversion
D. Error: cannot use static for function parameters
Answer» E.
34.

What will be the output of the program ? #include<stdio.h> int main() { char *str; str = "%s"; printf(str, "K n"); return 0; }

A. Error
B. No output
C. K
D. %s
Answer» D. %s
35.

Will the following program print the message infinite number of times? #include<stdio.h> #define INFINITELOOP while(1) int main() { INFINITELOOP printf("IndiaBIX"); return 0; }

A. Yes
B. No
Answer» B. No
36.

Will it result in to an error if a header file is included twice?

A. Yes
B. No
C. It is compiler dependent.
Answer» D.
37.

What will be the output of the program? #include<stdio.h> int main() { int arr[3] = {2, 3, 4}; char *p; p = arr; p = (char*)((int*)(p)); printf("%d, ", *p); p = (int*)(p+1); printf("%d", *p); return 0; }

A. 2, 3
B. 2, 0
C. 2, Garbage value
D. 0, 0
Answer» C. 2, Garbage value
38.

What will be the output of the program if the size of pointer is 4-bytes? #include<stdio.h> int main() { printf("%d, %d n", sizeof(NULL), sizeof("")); return 0; }

A. 2, 1
B. 2, 2
C. 4, 1
D. 4, 2
Answer» D. 4, 2
39.

What will be the output of the program ? #include<stdio.h> int main() { char *p; p="hello"; printf("%s n", *&amp*&p); return 0; }

A. llo
B. hello
C. ello
D. h
Answer» C. ello
40.

What will be the output of the program? #include<stdio.h> int main() { int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8}; int *p, *q; p = &arr[1][1][1]; q = (int*) arr; printf("%d, %d n", *p, *q); return 0; }

A. 8, 10
B. 10, 2
C. 8, 1
D. Garbage values
Answer» B. 10, 2
41.

What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes? #include<stdio.h> int main() { int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%u, %u, %u n", a[0]+1, *(a[0]+1), *(*(a+0)+1)); return 0; }

A. 448, 4, 4
B. 520, 2, 2
C. 1006, 2, 2
D. Error
Answer» D. Error
42.

Even if integer/float arguments are supplied at command prompt they are treated as strings.

A. True
B. False
Answer» B. False
43.

The first argument to be supplied at command-line must always be count of total arguments.

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

Which of the following is TRUE about argv?

A. It is an array of character pointers
B. It is a pointer to an array of character pointers
C. It is an array of strings
D. None of above
Answer» B. It is a pointer to an array of character pointers
45.

What will be the output of the program? #include<stdio.h> #define CUBE(x) (x*x*x) int main() { int a, b=3; a = CUBE(b++); printf("%d, %d n", a, b); return 0; }

A. 9, 4
B. 27, 4
C. 27, 6
D. Error
Answer» D. Error
46.

Point out the error in the program #include<stdio.h> #define SI(p, n, r) float si; si=p*n*r/100; int main() { float p=2500, r=3.5; int n=3; SI(p, n, r); SI(1500, 2, 2.5); return 0; }

A. 26250.00 7500.00
B. Nothing will print
C. Error: Multiple declaration of
D. <i class="C-code">si</i>
E. Garbage values
Answer» D. <i class="C-code">si</i>
47.

What will be the output of the program? #include&lt;stdio.h&gt; #define MAN(x, y) ((x)&gt;(y)) ? (x):(y); int main() { int i=10, j=5, k=0; k = MAN(++i, j++); printf("%d, %d, %d n", i, j, k); return 0; }

A. 12, 6, 12
B. 11, 5, 11
C. 11, 5, Garbage
D. 12, 6, Garbage
Answer» B. 11, 5, 11
48.

What will be the output of the program? #include&lt;stdio.h&gt; #define SQR(x)(x*x) int main() { int a, b=3; a = SQR(b+2); printf("%d n", a); return 0; }

A. 25
B. 11
C. Error
D. Garbage value
Answer» C. Error
49.

What will be the output of the program? #include&lt;stdio.h&gt; #define JOIN(s1, s2) printf("%s=%s %s=%s n", #s1, s1, #s2, s2); int main() { char *str1="India"; char *str2="BIX"; JOIN(str1, str2); return 0; }

A. str1=IndiaBIX str2=BIX
B. str1=India str2=BIX
C. str1=India str2=IndiaBIX
D. Error: in macro substitution
Answer» C. str1=India str2=IndiaBIX
50.

A text stream is an ordered sequence of characters composed into lines, each line consisting of zero or more characters plus a terminating new-line character.

A. True
B. False
Answer» B. False