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.

Which of the following cannot be used with ungetc?

A. scanf
B. getc
C. getchar
D. printf
Answer» E.
2.

Consider the declaration static char hello[ ] = " hello " ; The output of printf( " % s \ n ", hello) ; will be the same as that of

A. puts(" hello ");
B. puts( hello );
C. printf(" %s \ n", " hello ") ;
D. puts( " hello \ n ") ;
Answer» D. puts( " hello \ n ") ;
3.

sin(x) returns

A. sine of x where x is in radians
B. sine of x where x is in degree
C. cosine of x where x is in radians
D. cosine of x where x is in degree
Answer» B. sine of x where x is in degree
4.

The syntax for ungetc is

A. void ungetc(int c, FILE *fp)
B. int ungetc(int c, FILE *fp)
C. int ungetc(String c, FILE *fp)
D. int getc(int c, FILE *fp)
Answer» C. int ungetc(String c, FILE *fp)
5.

Consider following statements:putchar(getchar());putchar(getchar());Ifabis the input, then output will be

A. An error message
B. this can't be the input
C. a, b
D. Undefined
Answer» C. a, b
6.

What does the ungetc function return for the following expression? ungetc(c, fp); //where declarations are int c and FILE *fp

A. It returns character c
B. It returns EOF for an error
C. Both returns character c and returns EOF for an error
D. Either returns character c or returns EOF for an error
Answer» E.
7.

The following expression can be substituted for if (isalpha(c) && isdigit(c))

A. if (isalnum(c))
B. if (isalphanum(c))
C. if (isalphanumeric(c))
D. none of the mentioned
Answer» E.
8.

ungetc may be used with

A. scanf
B. getc
C. getchar
D. all of the mentioned
Answer» E.
9.

void * malloc(size_t n) returns

A. Pointer to n bytes of uninitialized storage
B. NULL if the request can be satisfied
C. Nothing
D. None of the mentioned
Answer» B. NULL if the request can be satisfied
10.

To instantiate an object with the statement ifstream items("C:inven.txt");the file on the disk is identified by the name

A. items
B. inven.txt
C. either (a) or (b)
D. None of these
Answer» C. either (a) or (b)
11.

The program fragment

A. 263
B. ASCII equivalent of 263
C. Rings the bell
D. undefined
Answer» D. undefined
12.

In a 'C' program, constant is defined

A. Before main
B. After main
C. Anywhere, but starting on a new line
D. Any where in the program
Answer» D. Any where in the program
13.

Output of the following 'C' program is

A. ffff
B. 0fff
C. 0000
D. Error
Answer» B. 0fff
14.

If abc is the input, then folloiwng program fragment results in

A. A syntax error
B. Garbage Values
C. Segmentation violation
D. Printing of 3
Answer» E.
15.

Output of this statment is :

A. Syntex Error
B. hello5
C. gives garbage value
D. print hello and terminates
Answer» C. gives garbage value
16.

Which statment is true about the given code ?

A. Goes in infinite loop
B. Gives Address of function main.
C. Gives garbage value
D. Compilation Error
Answer» C. Gives garbage value
17.

What is the output of this program, if input a is 1 and b is 2?

A. 1
B. 2
C. runtime error
D. compile time error
Answer» C. runtime error
18.

The following 'C' program

A. Counts the number of bits which are on in the number num
B. Sets all bits in the number num to 1
C. Sets bits in the number num to 0
D. Error
Answer» B. Sets all bits in the number num to 1
19.

Comment on the given statment:

A. Will execute without any error
B. Will give Segmentation fault
C. Will give Compilation Error
D. None of the above
Answer» C. Will give Compilation Error
20.

Result of the execution of the following "C" program fragment is

A. An execution error
B. A syntax error
C. Printing of k
D. Garbage Value
Answer» D. Garbage Value
21.

Find output of following :

A. i5h4g3f2e1
B. 14h3g2f1e0
C. An error message
D. Infinite Loop
Answer» B. 14h3g2f1e0
22.

Find the output of following code segment

A. A syntax error
B. Cartrta
C. Catrat
D. Catratratratrat...
Answer» E.
23.

If the following program fragment(assume negative numbers are stored in 2's complement form), output is (log in answers are to the base two)

A. An unpredictable value
B. 8*log(x+3)
C. log(x+3)
D. None of these
Answer» D. None of these
24.

Output of the following program fragment (in C) is

A. 1 2 3 4 5
B. 1 2 4
C. 2 4 5
D. none of these
Answer» C. 2 4 5
25.

The following code fragment

A. prints 8
B. prints 6
C. prints 6 or 8 depending on the compiler implementation
D. is syntactically wrong
Answer» D. is syntactically wrong
26.

The following program fragment  prints

A. garbage
B. -3
C. an integer that changes from machine to machine
D. none of above
Answer» D. none of above
27.

If the following program fragment ( assume negative numbers are stored in 2's complement form) outputs an integer that is same as (log in the answers are to the base two)

A. an unpredictable value
B. 8 * log( x + 3 )
C. log( x+ 3 )
D. none of above
Answer» D. none of above
28.

The program fragment:

A. prints 263
B. prints the ASCll equivalent of 263
C. rings the bell
D. prints garbage
Answer» D. prints garbage
29.

The following program fragment results in

A. an execution error
B. a syntax error
C. printing of k
D. none of the above
Answer» D. none of the above
30.

The following program fragment

A. prints 0
B. prints a non-zero value
C. is illegal
D. prints an unpredictable value
Answer» B. prints a non-zero value
31.

Consider the following program. If Madam is the required output, then the body of first ( ) must be

A. empty
B. second( ) ; putchar ( 'a' );
C. putchar( 'a' ) ; second(); printf ("%c", 'a' );
D. none of the above
Answer» D. none of the above
32.

The following program

A. is illegal
B. keeps on printing tim
C. prints tim once
D. none of the above
Answer» C. prints tim once
33.

Consider the program. If the machine in which this program is executed is little-endian (meaning, the lower signifi-cant digits occupy lower addresses), then the output will he

A. 0
B. 99999999
C. 1
D. unpredictable
Answer» D. unpredictable
34.

The following program results in

A. printing of a garbage number
B. an execution error
C. printing of starting address of the function main
D. an infinite loop
Answer» D. an infinite loop
35.

The following piece of code

A. results in syntax error
B. prints 7
C. prints 8
D. none of above
Answer» C. prints 8
36.

A possible output of the following program fragment  is

A. 262164 262164 262164
B. 262164 262165 262166
C. 262164 262165 262165
D. 262164 262164 262165
Answer» B. 262164 262165 262166
37.

What is the output of the following program segment?

A. 5
B. 20
C. 0
D. none of above
Answer» D. none of above
38.

The following program outputs

A. LTTE
B. TELO
C. JKLF
D. PLO
Answer» B. TELO
39.

The program prints

A. 2
B. 5
C. 1
D. 6
Answer» D. 6
40.

The output of the following program will be

A. 8
B. 12
C. 9
D. 6
Answer» B. 12
41.

What is the output of this code considering user typed jkl?

A. jkl
B. kl
C. Undefined behaviour
D. jk
Answer» B. kl
42.

x - = y + 1;  means

A. x = x - y + 1
B. x = -x -y -1
C. x=-x +y + 1
D. x= x - y -1
Answer» E.
43.

The contents of a file will be lost if it is opened in

A. a mode
B. w mode
C. w+ mode
D. a+  mode
Answer» D. a+  mode
44.

The function fopen("filename","r")returns

A. Nothing
B. A value 0 or 1 depending on whether the file could be opened or not.
C. A pointer to FILE filename,if it exits
D. A pointer to a new file after creating it.
Answer» D. A pointer to a new file after creating it.
45.

The statement printf ( "%d" , sizeof (" "')); prints

A. an error message
B. 0
C. garbage
D. 1
Answer» E.
46.

The function sprintf()works like printf(),but operatres on

A. Data in a file
B. stderr
C. stdin
D. string
Answer» E.
47.

Size of an array can be evaluated by: (Assuming array declaration int a[10];)

A. sizeof(a);
B. sizeof(*a);
C. sizeof(a[10]);
D. 10 * sizeof(a);
Answer» B. sizeof(*a);
48.

%f access specifier is used for

A. Strings
B. Integral types
C. Floating type
D. All of the mentioned
Answer» D. All of the mentioned
49.

Which of the following fopen statements are illegal?

A. fp = fopen(“abc.txt”, “r”);
B. fp = fopen(“/home/user1/abc.txt”, “w”);
C. fp = fopen(“abc”, “w”);
D. none of the mentioned
Answer» E.
50.

Which is true about getc returns?

A. The next character from the stream is not referred by file pointer
B. EOF for end of file or error
C. Nothing
D. None of the mentioned
Answer» C. Nothing