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 will be the output of the program? #include<stdio.h> int main() { void fun(char*); char a[100]; a[0] = 'A'; a[1] = 'B'; a[2] = 'C'; a[3] = 'D'; fun(&a[0]); return 0; } void fun(char *a) { a++; printf("%c", *a); a++; printf("%c", *a); }

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

Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; }

A. The function calculates the value of 1 raised to power num.
B. The function calculates the square root of an integer
C. The function calculates the factorial value of an integer
D. None of above
Answer» D. None of above
3.

Assuming, integer is 2 byte, What will be the output of the program? #include<stdio.h> int main() { printf("%x n", -2<<2); return 0; }

A. ffff
B. 0
C. fff8
D. Error
Answer» D. Error
4.

What will be the output of the program? #include<stdio.h> int main() { int i=-3, j=2, k=0, m; m = ++i || ++j && ++k; printf("%d, %d, %d, %d n", i, j, k, m); return 0; }

A. 2, 2, 0, 1
B. 1, 2, 1, 0
C. -2, 2, 0, 0
D. -2, 2, 0, 1
Answer» E.
5.

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

A. z=0
B. z=1
C. z=4
D. z=2
Answer» C. z=4
6.

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

A. 1, 0, 1
B. 1, 1, 1
C. 0, 0, 0
D. 0, 1, 0
Answer» D. 0, 1, 0
7.

What will be the output of the program? #include<stdio.h> int main() { float a=0.7; if(a < 0.7) printf("C n"); else printf("C++ n"); return 0; }

A. C
B. C++
C. Compiler error
D. Non of above
Answer» B. C++
8.

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

A. 1250
B. 2
C. 50
D. 250
Answer» E.
9.

What will be the output of the program? #include<stdio.h> int main() { float *p; printf("%d n", sizeof(p)); return 0; }

A. 2 in 16bit compiler, 4 in 32bit compiler
B. 4 in 16bit compiler, 2 in 32bit compiler
C. 4 in 16bit compiler, 4 in 32bit compiler
D. 2 in 16bit compiler, 2 in 32bit compiler
Answer» B. 4 in 16bit compiler, 2 in 32bit compiler
10.

What will be the output of the program if value 25 given to scanf()? #include<stdio.h> int main() { int i; printf("%d n", scanf("%d", &i)); return 0; }

A. 25
B. 2
C. 1
D. 5
Answer» D. 5
11.

What will be the output of the program ? #include<stdio.h> int main() { printf("%c n", ~('C'*-1)); return 0; }

A. A
B. B
C. C
D. D
Answer» C. C
12.

What will be the output of the program ? #include<stdio.h> int main() { FILE *fp; unsigned char ch; /* file 'abc.c' contains "This is IndiaBIX " */ fp=fopen("abc.c", "r"); if(fp == NULL) { printf("Unable to open file"); exit(1); } while((ch=getc(fp)) != EOF) printf("%c", ch); fclose(fp); printf(" n", ch); return 0; }

A. This is IndiaBIX
B. This is
C. Infinite loop
D. Error
Answer» D. Error
13.

What will be the output of the program ? #include<stdio.h> int main() { char *p; p="%d n"; p++; p++; printf(p-2, 23); return 0; }

A. 21
B. 23
C. Error
D. No output
Answer» C. Error
14.

What will be the output of the program ? #include<stdio.h> int main() { FILE *fp; char ch, str[7]; fp=fopen("try.c", "r"); /* file 'try.c' contains "This is Nagpur" */ fseek(fp, 9L, SEEK_CUR); fgets(str, 5, fp); puts(str); return 0; }

A. agpur
B. gpur
C. Nagp
D. agpu
Answer» E.
15.

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

A. %%%%%
B. %%
C. No output
D. Error
Answer» C. No output
16.

What will be the output of the program? #include<stdio.h> int i; int fun(); int main() { while(i) { fun(); main(); } printf("Hello n"); return 0; } int fun() { printf("Hi"); }

A. Hello
B. Hi Hello
C. No output
D. Infinite loop
Answer» B. Hi Hello
17.

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

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

What will be the output of the program? #include<stdio.h> int main() { float fval=7.29; printf("%d n", (int)fval); return 0; }

A. 0
B. 0.0
C. 7.0
D. 7
Answer» E.
19.

What will be the output of the program? #include<stdio.h> #include<math.h> int main() { printf("%d, %d, %d n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l)); return 0; }

A. 4, 4, 4
B. 4, 8, 8
C. 4, 8, 10
D. 4, 8, 12
Answer» D. 4, 8, 12
20.

What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h> int main() { int fun(); int i; i = fun(); printf("%d n", i); return 0; } int fun() { _AX = 1990; }

A. Garbage value
B. 0 (Zero)
C. 1990
D. No output
Answer» D. No output
21.

What will be the output of the program? #include<stdio.h> int reverse(int); int main() { int no=5; reverse(no); return 0; } int reverse(int no) { if(no == 0) return 0; else printf("%d,", no); reverse (no--); }

A. Print 5, 4, 3, 2, 1
B. Print 1, 2, 3, 4, 5
C. Print 5, 4, 3, 2, 1, 0
D. Infinite loop
Answer» E.
22.

What will be the output of the program? #include<stdio.h> void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int); int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n > 0) { fun(--n); printf("%d,", n); fun(--n); } }

A. 0, 2, 1, 0,
B. 1, 1, 2, 0,
C. 0, 1, 0, 2,
D. 0, 1, 2, 0,
Answer» E.
23.

Point out the error in the program? #include<stdio.h> /* Assume there is a file called 'file.c' in c: tc directory. */ int main() { FILE *fp; fp=fopen("c: tc file.c", "r"); if(!fp) printf("Unable to open file."); fclose(fp); return 0; }

A. No error, No output.
B. Program crashes at run time.
C. Output: Unable to open file.
D. None of above
Answer» D. None of above
24.

Which of the following statement is correct about the program? #include<stdio.h> int main() { FILE *fp; char ch; int i=1; fp = fopen("myfile.c", "r"); while((ch=getc(fp))!=EOF) { if(ch == ' n') i++; } fclose(fp); return 0; }

A. The code counts number of characters in the file
B. The code counts number of words in the file
C. The code counts number of blank lines in the file
D. The code counts number of lines in the file
Answer» E.
25.

Which of the following statement is correct about the program? #include<stdio.h> int main() { FILE *fp; char str[11], ch; int i=0; fp = fopen("INPUT.TXT", "r"); while((ch=getc(fp))!=EOF) { if(ch == ' n' || ch == ' ') { str[i]=' 0'; strrev(str); printf("%s", str); i=0; } else str[i++]=ch; } fclose(fp); return 0; }

A. The code writes a text to a file
B. The code reads a text files and display its content in reverse order
C. The code writes a text to a file in reverse order
D. None of above
Answer» C. The code writes a text to a file in reverse order
26.

What will be the output of the program ? #include<stdio.h> int main() { float a=3.15529; printf("%2.1f n", a); return 0; }

A. 3.00
B. 3.15
C. 3.2
D. 3
Answer» D. 3
27.

Point out the correct statements about the program? #include<stdio.h> int main() { FILE *fptr; char str[80]; fptr = fopen("f1.dat", "w"); if(fptr == NULL) printf("Cannot open file"); else { while(strlen(gets(str))>0) { fputs(str, fptr); fputs(" n", fptr); } fclose(fptr); } return 0; }

A. The code copies the content of one file to another
B. The code writes strings that are read from the keyboard into a file.
C. The code reads a file
D. None of above
Answer» C. The code reads a file
28.

What will be the output of the program ? #include<stdio.h> int main() { int k=1; printf("%d == 1 is" "%s n", k, k==1?"TRUE":"FALSE"); return 0; }

A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. K == 1 is FALSE
Answer» C. 1 == 1 is FALSE
29.

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

A. char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}
B. char *str = %c%s%c; main(){ printf(str, 34, str, 34);}
C. No output
D. Error in program
Answer» B. char *str = %c%s%c; main(){ printf(str, 34, str, 34);}
30.

If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of below program? #include<stdio.h> int main() { FILE *fs, *ft; char c[10]; fs = fopen("source.txt", "r"); c[0] = getc(fs); fseek(fs, 0, SEEK_END); fseek(fs, -3L, SEEK_CUR); fgets(c, 5, fs); puts(c); return 0; }

A. friend
B. frien
C. end
D. Error in
E. <i class="C-code">fseek();</i>
Answer» D. Error in
31.

What will be the output of the program ? #include&lt;stdio.h&gt; int main() { FILE *ptr; char i; ptr = fopen("myfile.c", "r"); while((i=fgetc(ptr))!=NULL) printf("%c", i); return 0; }

A. Print the contents of file "myfile.c"
B. Print the contents of file "myfile.c" upto NULL character
C. Infinite loop
D. Error in program
Answer» D. Error in program
32.

While calling the fprintf() function in the format string conversion specifier %s can be used to write a character string in capital letters.

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

The maximum combined length of the command-line arguments including the spaces between adjacent arguments is

A. 128 characters
B. 256 characters
C. 67 characters
D. It may vary from one operating system to another
Answer» E.
34.

Which of the following statements are correct about the program? #include&lt;stdio.h&gt; char *fun(unsigned int num, int base); int main() { char *s; s=fun(128, 2); s=fun(128, 16); printf("%s n",s); return 0; } char *fun(unsigned int num, int base) { static char buff[33]; char *ptr = &amp;buff[sizeof(buff)-1]; *ptr = ' 0'; do { *--ptr = "0123456789abcdef"[num %base]; num /=base; }while(num!=0); return ptr; }

A. It converts a number to a given base.
B. It converts a number to its equivalent binary.
C. It converts a number to its equivalent hexadecimal.
D. It converts a number to its equivalent octal.
Answer» B. It converts a number to its equivalent binary.
35.

What will be the output of the program? #include&lt;stdio.h&gt; int main() { const c = -11; const int d = 34; printf("%d, %d n", c, d); return 0; }

A. Error
B. -11, 34
C. 11, 34
D. None of these
Answer» C. 11, 34
36.

Which of the following statements are correct about the below C-program? #include&lt;stdio.h&gt; int main() { int x = 10, y = 100%90, i; for(i=1; i&lt;10; i++) if(x != y); printf("x = %d y = %d n", x, y); return 0; } 1 : The printf() function is called 10 times. 2 : The program will produce the output x = 10 y = 10 3 : The ; after the if(x!=y) will NOT produce an error. 4 : The program will not produce output.

A. 1
B. 2, 3
C. 3, 4
D. 4
Answer» C. 3, 4
37.

Which of the following sentences are correct about a for loop in a C program? 1: for loop works faster than a while loop. 2: All things that can be done using a for loop can also be done using a while loop. 3: for(;;); implements an infinite loop. 4: for loop can be used if we want statements in a loop get executed at least once.

A. 1
B. 1, 2
C. 2, 3
D. 2, 3, 4
Answer» E.
38.

Which of the following statements are correct about the below program? #include&lt;stdio.h&gt; int main() { int n = 0, y = 1; y == 1 ? n=0 : n=1; if(n) printf("Yes n"); else printf("No n"); return 0; }

A. Error: Declaration terminated incorrectly
B. Error: Syntax error
C. Error: Lvalue required
D. None of above
Answer» D. None of above
39.

What will be the output of the program ? #include&lt;stdio.h&gt; int main() { char *str; str = "%d n"; str++; str++; printf(str-2, 300); return 0; }

A. No output
B. 30
C. 3
D. 300
Answer» E.
40.

Is this a correct way for NULL pointer assignment? int i=0;char *q=(char*)i;

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

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes? #include&lt;stdio.h&gt; int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u n", a+1, &amp;a+1); return 0; }

A. 65474, 65476
B. 65480, 65496
C. 65480, 65488
D. 65474, 65488
Answer» C. 65480, 65488
42.

What will be the output of the program ? #include&lt;stdio.h&gt; #include&lt;string.h&gt; int main() { char sentence[80]; int i; printf("Enter a line of text n"); gets(sentence); for(i=strlen(sentence)-1; i &gt;=0; i--) putchar(sentence[i]); return 0; }

A. The sentence will get printed in same order as it entered
B. The sentence will get printed in reverse order
C. Half of the sentence will get printed
D. None of above
Answer» C. Half of the sentence will get printed
43.

What will be the output of the program ? #include&lt;stdio.h&gt; struct course { int courseno; char coursename[25]; }; int main() { struct course c[] = { {102, "Java"}, {103, "PHP"}, {104, "DotNet"} }; printf("%d ", c[1].courseno); printf("%s n", (*(c+2)).coursename); return 0; }

A. 103 DotNet
B. 102 Java
C. 103 PHP
D. 104 DotNet
Answer» B. 102 Java
44.

Point out the error in the program? struct emp { int ecode; struct emp *e; };

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

We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch?

A. Yes
B. No
Answer» B. No
46.

If scanf() is used to store a value in a char variable then along with the value a carriage return( r) also gets stored it.

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

The way the break is used to take control out of switch and continue to take control of the beginning of the switch?

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

By default, the data type of a constant without a decimal point is int, whereas the one with a decimal point is a double.

A. Yes
B. No
Answer» B. No
49.

A char variable can store either an ASCII character or a Unicode character.

A. True
B. False
Answer» B. False
50.

Which of the following statements are correct about the below program? #include&lt;stdio.h&gt; int main() { int i = 10, j = 20; if(i = 5) &amp;&amp; if(j = 10) printf("Have a nice day"); return 0; }

A. Output: Have a nice day
B. No output
C. Error: Expression syntax
D. Error: Undeclared identifier
E. <i class="C-code">if</i>
Answer» D. Error: Undeclared identifier