Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Basic C MCQ - Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 51

PSG COLLEGE OF TECHNOLOGY, COIMBATORE – 641 004

Degree : M.Sc
Branch : SS / TCS / DS / CS / AM
Course Code : 20XW15/XT14/XD14/XC15/SA16
Course Name : PROBLEM SOLVING AND C PROGRAMMING

Use the question paper format which is available from the next page:

INSTRUCTIONS FOR TYPING THE QUESTION PAPER IN THE FORMAT:

Field Instructions

• Question Type - Do not change


• Question number - Type the question number
• Question - Type the actual question
(Text, Images, Formulae)
• Option - Type answer options against the given option
numbers 1-4. Leave the option 5 blank.
• Question Metadata - Do not fill-in the “Difficulty Level” and “Blooms Taxonomy”.
• Type ‘Y’ against the correct answer option only
Question Type Basic MCQ

Question 1
number
Question Consider the following C code. Which of the following is
true?
char *f="%d\n";
printf(f, 10);
Option No Option Correct(Y)
Option 1 is valid and prints the number 10, followed by a Y
newline character
Option 2 Is NOT valid and compile time error will be thrown
Option 3 Is valid and nothing will be printed
Option 4 Runtime error will be thrown
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 2
number
Question If s1 and s2 are two string variables, and i is an integer
variable; which of the following lines is NOT a valid use of
string functions?
Option No Option Correct(Y)
Option 1 strcmp(i, s1); Y
Option 2 strcpy(s2, s1);
Option 3 strcat(s1, s2+i);
Option 4 i = strlen(s1);
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 3
number
Question If p and q are pointers to int, pointing to elements of an array,
which of the following statements is not valid:
Option No Option Correct(Y)
Option 1 p = q + 2;
Option 2 *p = p - q;
Option 3 *p = p + q; Y
Option 4 *p = *p + *q;
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 4
number
Question Suppose that we would like to write a C program to read from
a text file named hello.txt and print its content to the screen.
To do this, we use a file pointer fp. Which of the following
four statements should we use to open this file?
Option No Option Correct(Y)
Option 1 fp = fopen("hello.txt", "w");
Option 2 fp = fopen("hello.txt", "a");
Option 3 fopen(fp, "hello.txt");
Option 4 fp = fopen("hello.txt", "r"); Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 5
number
Question Suppose that the following declarations are in effect:
int a[] = {17, 14, 10, -5, 14, 19};
int *p = &a[1];
int *q = &a[4];
Which of the following four logical expressions evaluates to
false?
Option No Option Correct(Y)
Option 1 p<q
Option 2 *p == *q
Option 3 a<p
Option 4 p == q Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 6
number
Question What will be the output of the following C program?
#include <stdio.h>
int main(void) {
char s[] = "Happy Programming";
printf("%c\n", s[1]);
printf("%s\n", s+6);
*(s+5) = '\0';
printf("%s\n", s);
return 0;
}
Option No Option Correct(Y)
Option 1 Illegal Operation
Option 2 a Y
Programming
Happy
Option 3 Happy Programming
Option 4 appy
gramming
Pro
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 7
number
Question What will be the output of the following C Program?
#include <stdio.h>
int main(void) {
int i = 4, j = 8;
int *p = &i;
int *q;
int *r = &j;
*r = *p;
q = p;
(*q)--;
printf("%d %d %d", *p, *q, *r);
}

Option No Option Correct(Y)


Option 1 483
Option 2 333
Option 3 334 Y
Option 4 434
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 8
number
Question The following user defined function is supposed to create an
identical copy of a string and returns a pointer that points to it.
Which of the following statements correctly describes it?
char *duplicate(char *p) {
char *q;
strcpy(q, p);
return q;
}
Option No Option Correct(Y)
Option 1 Correct code and it will perform the task.
Option 2 Syntax Error function cannot return pointer
Option 3 Runtime Error: Segmentation fault as q is pointing Y
to unknown location.
Option 4 No error. But it will not do the expected operation.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 9
number
Question Which of the following statements regarding streams and files
in the C programming language is INCORRECT?
Option No Option Correct(Y)
Option 1 In C, a stream is any source of input or any
destination of output;
Option 2 The following statement will output “out of Y
memory” followed by a newline character to
the standard error channel:
fprintf(stdout, "out of memory\n");
Option 3 The fopen function returns NULL when it fails
to open a file;
Option 4 The notion of lines does NOT apply to binary
files.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 10
number
Question If c is a variable of type char, which one of the following
statements is illegal?
Option No Option Correct(Y)
Option 1 i += c; /* i has type int */
Option 2 c = 2 * c - 1;
Option 3 printf(c); Y
Option 4 putchar(c);
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 11
number
Question Suppose that the following declarations are in effect:
int a[] = {17, 211, 10, -5, 14, 19};
int *p = &a[3];
What is the value of *(p+2)?
Option No Option Correct(Y)
Option 1 10
Option 2 -5
Option 3 14
Option 4 19 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 12
number
Question What is the output of the following program?
#include <stdio.h>
#include <string.h>
int main() {
char s[90] = "test";
char *p = "program";
printf("%d %d\n", strlen(s), strlen(p+2));
puts(strcat(s, p));
printf("%d\n", strlen(s));
return 0;
}

Option No Option Correct(Y)


Option 1 45 Y
testprogram
11
Option 2 Illegal Operation
Option 3 47
test
4
Option 4 45
test
4
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 13
number
Question In the following piece of C code, what will be the value of x?
int a = 3, b;
int x = 2 * (b = a) + (a = 1);
Option No Option Correct(Y)
Option 1 7 or 3 depends on the compiler execution order of Y
()
Option 2 Always 7
Option 3 Sometimes 7 and sometimes 3
Option 4 Always 3
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 14
number
Question What does the following piece of code compute?
int num;
for (num = 100; 1; ++num) {
for (int div = 2; div < num; ++div) {
if (!(num % div)) {
goto label;
}
}
break;
label: ;
}
printf("num = %d\n", num);
Option No Option Correct(Y)
Option 1 Computes a prime number no less than 100
Option 2 Computes the largest prime number no less
than 100
Option 3 Computes the smallest prime number no less Y
than 100
Option 4 Computes the smallest prime number greater
than 100
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 15
number
Question For the following statement, state what the output is when
they are executed.
int a = 0;
int b = 3;
if (a != 0 && b % a == 0) {
printf("%d divides %d\n", a, b);
}
else {
printf("%d does not divide %d\n", a, b);
}
Option No Option Correct(Y)
Option 1 0 divides 3
Option 2 0 does not divide 3 Y
Option 3 Runtime Error a % b is illegal
Option 4 No Error. No output.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 16
number
Question What does the following expression print? Assume a is of int
type.
if (a = 0) {
printf("a is zero");
}
else {
printf("a is non-zero");
}
Option No Option Correct(Y)
Option 1 a is zero
Option 2 Error in if condition
Option 3 a is non-zero Y
Option 4 Runtime Error
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 17
number
Question If a is a number between 0 and 99, what does the following
code print?
char a1 = '0' + (a / 10);
char a0 = '0' + (a % 10);
printf("%c%c", a1, a0);
Option No Option Correct(Y)
Option 1 This will print two junk characters
Option 2 This prints the value of a as a two-digit number. Y
Option 3 This prints the value of a
Option 4 This prints the char equivalent of the value of a
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 18
number
Question Consider the following code segment. What will be printed?
int i = 1; int j = 2;
if (i) {
int i;
i = j;
j = 0;
}
printf("%d %d", i, j);

Option No Option Correct(Y)


Option 1 2 2
Option 2 1 2
Option 3 2 0
Option 4 1 0 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 19
number
Question #include <stdio.h>
int mystery(int n);
int main() {
int n = 3;
printf("%d %d\n", n <= 1, mystery(n));
return 0;
}
int mystery(int n) {
if (n <= 1)
return 1;
else
return (mystery(n-1) + n);
}
What will be the output of the above program?
Option No Option Correct(Y)
Option 1 0 6 Y
Option 2 0 Garbage Value
Option 3 1 6
Option 4 1 Garbage Value
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 20
number
Question Compilation is the step in the software development cycle
where this type of errors are detected.
Option No Option Correct(Y)
Option 1 Logic Errors
Option 2 Syntax Errors Y
Option 3 Semantic Errors
Option 4 Specification Errors
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 21
number
Question Comments / documentation are meant for _____ rather than
the computer and provide explanation of the actual code.
Option No Option Correct(Y)
Option 1 Barcode readers
Option 2 Compiler to understand the logic
Option 3 Human readers Y
Option 4 To select the compiler
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 22
number
Question The actual arguments in a function call have to match the
_____ of parameters that appear in the function definition
Option No Option Correct(Y)
Option 1 number
Option 2 type
Option 3 number and type Y
Option 4 number, type and name
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 23
number
Question Suppose the following code segment is executed, what will be
the value of z?
int x,y,z;
x=3;
y=7;
z=9;
if (x>y)
if (x-y == 4)
z = 33;
else
z=77;

Option No Option Correct(Y)


Option 1 77
Option 2 9 Y
Option 3 33
Option 4 Either 33 or 77
Option 5 Either 9 or 77
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 24
number
Question Suppose the following code segment is executed, what will be
the value of z?
int a,b,z;
a = 1;
b = 4;
while (a<b) {
a = 2 * a;
b = b +1;
}
z = b;

Option No Option Correct(Y)


Option 1 5
Option 2 6
Option 3 9
Option 4 7 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 25
number
Question Pick the best statement for the following program.
#include <stdio.h>
int foo(int a) {
printf("%d",a);
return 0;
}
int main( ) {
foo;
return 0;
}
Option No Option Correct(Y)
Option 1 It’ll result in compile error because foo is used
without parentheses
Option 2 No compile error and some garbage value
would be passed to foo function. This would
make foo to be executed with output “garbage
integer”.
Option 3 No compile error but foo function wouldn’t be Y
executed. The program wouldn't print anything.
Option 4 No compile error and ZERO (i.e. 0) would be
passed to foo function. This would make foo to
be executed with output 0
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 26
number
Question "C is strongly typed" means...

Option No Option Correct(Y)


Option 1 you need strong typing and keyboarding skills
to be a C programmer
Option 2 there is a strongly defined type or category to
which the C programming language belongs.
Option 3 every value has a type, and C cares about what Y
those types are.
Option 4 you can never assign a variable of type int to a
variable of type double.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 27
number
Question Which of the following could NOT be a variable name in
C?
Option No Option Correct(Y)
Option 1 1st_value Y
Option 2 v300000
Option 3 integer
Option 4 Double
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 28
number
Question What is the value of the following expression (given the
following declarations)?

int a = 8;
int b = 2;
int c = 4;

a+b/c*a-c/b
Option No Option Correct(Y)
Option 1 10.0
Option 2 4
Option 3 6 Y
Option 4 10
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 29
number
Question Which of the following was NOT given as a motivation for
using functions in programming?
Option No Option Correct(Y)
Option 1 Functions raise the level of discourse
Option 2 Functions are more efficient (run faster) than Y
the same solution without functions
Option 3 That's how modern programming is done
Option 4 Functions permit code to be shared between
programs.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 30
number
Question Suppose x is a double. After the statements
x = 5.9;
a = (int) x;
have executed, what is the value of x?
Option No Option Correct(Y)
Option 1 5.9 Y
Option 2 5
Option 3 5.0
Option 4 6
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 31
number
Question Choose the best conclusion to the statement.
In C, the word double…
Option No Option Correct(Y)
Option 1 is a special, floating point value
Option 2 must be part of the declaration of every variable
which will hold numeric values.
Option 3 is available for use as a variable name.
Option 4 is a reserved word. Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 32
number
Question Suppose # is a left-associative binary operator which has
lower precedence than +. Given the following expression,
which expression is equivalent to it?
3+5#6#7
Option No Option Correct(Y)
Option 1 3 + (5 # (6 # 7))
Option 2 (3 + 5) # (6 # 7)
Option 3 3 + ((5 # 6) # 7)
Option 4 ((3 + 5) # 6) # 7 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 33
number
Question For the operators *, +, /, %, -, which of the following
statements about precedence in C is true:
Option No Option Correct(Y)
Option 1 Highest +, /, *
Lowest %, -
Option 2 Highest *, /, % Y
Lowest +, -
Option 3 Highest *, %, -
Lowest /, +
Option 4 Highest *, +, %
Lowest -, /
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 34
number
Question If you see the following line in an error-free C program:

y = combine (a / b + c);

which statement could not be true:


Option No Option Correct(Y)
Option 1 b is used in this line as an argument (actual
parameter) of combine.
Option 2 combine does not have a "void" return value.
Option 3 The function combine has three formal Y
parameters.
Option 4 The definition of combine contains one and
only one return statement.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 35
number
Question Suppose a valid C program contains the statement
TREE = TRUNK;

Which of the following is true? (Don't assume anything about


the style used in naming identifiers.)
Option No Option Correct(Y)
Option 1 TREE and TRUNK must both be #defines.
Option 2 TREE must be a #define but TRUNK doesn't
have to be
Option 3 TRUNK must be a #define but TREE doesn't
have to be.
Option 4 TREE cannot be a #define but TRUNK might Y
be.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 36
number
Question In C, the value of a condition can be thought of informally as
"yes" or "no" but is actually represented by the values
Option No Option Correct(Y)
Option 1 true or false
Option 2 TRUE or FALSE
Option 3 1 or 1
Option 4 non-zero (usually 1) or 0 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 37
number
Question #include <stdio.h>

int F1 (int a) {
a = 2;
return 3;
}

int main (void) {


int a;
a = 0;
a = 4;
a = F1 (a); /*line 1*/
printf ("a = %d", a);
return 0;
}

When this program runs, what will it display (assume no


syntax errors, except possibly as indicated in the answers)
Option No Option Correct(Y)
Option 1 Won't run: line 1 has a syntax error
Option 2 a=0
Option 3 a=3 Y
Option 4 a=2
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 38
number
Question The following function is supposed to find the smallest
among four characters. Choose the best answer.

char smallest_of_4 (char c1, char c2, char c3, char c4) {
char smallest_of_1and2, smallest_of_3and4;
char smallest_of_all;

if (c1 <= c2)


smallest_of_1and2 = c1;
else
smallest_of_1and2 = c2;
if (c3 <= c4)
smallest_of_3and4 = c3;
else
smallest_of_3and4 = c4;
if (smallest_of_1and2 <= smallest_of_3and4)
smallest_of_all = smallest_of_1and2;
else
smallest_of_all = smallest_of_3and4;

return smallest_of_all;
}
Option No Option Correct(Y)
Option 1 This function always gives the right answer. Y
Option 2 This function never gives the right answer.
Option 3 If c1 happens to be the smallest character, this
function gives the right answer (regardless of
the values of c2, c3, c4). If c1 is not the
smallest character, some values of c2, c3, or c4
will cause it to give a wrong answer.
Option 4 If c3 is less than either c1 or c2, this function
always gives the right answers. If c3 is not less
than c1 or c2, it gives some incorrect answers.
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 39
number
Question What is printed by main when this program fragment runs?

int F1 (int veggie) {


return veggie + 1;
}

int main (void) {


int veggie= 2, onion = 3;
onion = F1 (4);
printf ("%d %d", veggie, onion);
}
Option No Option Correct(Y)
Option 1 12
Option 2 25 Y
Option 3 33
Option 4 23
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 40
number
Question For which values of x is the following condition true? You
may assume that x is a positive integer.

(2 % (x + 1)) > 0
Option No Option Correct(Y)
Option 1 true for all even values of x
Option 2 true for all odd values of x
Option 3 true for all positive values of x
Option 4 true when x is greater than 1 Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 41
number
Question Saying "A invokes B" is the same as saying

Option No Option Correct(Y)


Option 1 A is called by B
Option 2 B calls A
Option 3 B is the callee, and A is the caller Y
Option 4 A returns to B
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 42
number
Question Assume the following.
sizeof(int) = 4 bytes
sizeof(char *) = 4 bytes
sizeof(char) = 1 byte
What is the output of the code below on a 32bit machine?

#include int main() {


int number = 20;
char *ptr;
ptr = (char *) &number;
printf("%x",*ptr);
return 0;
}

Option No Option Correct(Y)


Option 1 Invalid operation
Option 2 14 Y
Option 3 Some Junk value
Option 4 20
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 43
number
Question What is the output of the code below?
#include <stdio.h>
int main() {
char string[] = "BADGERS";
char *ptr = string;
*ptr = *ptr + 2;
ptr = ptr + 2;
printf("%c", *ptr);
ptr--;
printf("%c", *ptr);
ptr = string;
printf("%c", *ptr);
return 0;
}
Option No Option Correct(Y)
Option 1 DAB
Option 2 BAD
Option 3 BAB
Option 4 DAD Y
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 44
number
Question What is the size (in bytes) for the following structures on a
32bit machine installed with the Linux Operating System?
sizeof(int) = 4 bytes
sizeof(short) = 2 bytes
sizeof(char) = 1 byte

struct foo {
int d1;
int d2;
char c1;
char *c2;
short s;
};

Option No Option Correct(Y)


Option 1 12
Option 2 10
Option 3 15 Y
Option 4 16
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 45
number
Question Suppose that x and y have byte values 0x93 and 0x3F,
respectively. Find the byte value of the following C
expression.
!x || !y
Option No Option Correct(Y)
Option 1 0 Y
Option 2 1
Option 3 Illegal Operation
Option 4 Compiler dependent
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 46
number
Question Output of the following program?
#include <stdio.h>
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
return 0;
}

Option No Option Correct(Y)


Option 1 4321
Option 2 0000 Y
Option 3 1234
Option 4 5555
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 47
number
Question What will be the output of the following C program segment?

char inChar = ‘A’ ;

switch ( inChar ) {
case ‘A’ : printf (“Choice A”) ;

case ‘B’ :

case ‘C’ : printf (“Choice B”) ;

case ‘D’ :

case ‘E’ :
default : printf ( “ No Choice” ) ;
}

Option No Option Correct(Y)


Option 1 No Choice
Option 2 Choice A
Option 3 Choice A Choice B No Choice Y
Option 4 Program gives no output as it is erroneous
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 48
number
Question Consider the following program,
main( )
{
int x = 49;
for(;x;)
x--;
printf(“%d\n”, x);
}
What will be the output of the program?

Option No Option Correct(Y)


Option 1 49
Option 2 0 Y
Option 3 -49
Option 4 Infinite Loop
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 49
number
Question What will be the output of the following C code?
#include <stdio.h>
int main()
{
short i;
for (i = 1; i >= 0; i++)
printf("%d\n", i);

}
Option No Option Correct(Y)
Option 1 The control won’t fall into the for loop
Option 2 Numbers will be displayed until the signed limit of
short and throw a runtime error
Option 3 Numbers will be displayed until the signed limit of Y
short and program will successfully terminate
Option 4 This program will get into an infinite loop and keep
printing numbers with no errors
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply
Question Type Basic MCQ

Question 50
number
Question What will be the output of the following C code?

void main()
{
int i=5;
while(i<=10) {
(i>2)?i++:i--;
printf(“%3d”, i);
}
}
Option No Option Correct(Y)
Option 1 6 7 8 9 10 11 Y
Option 2 6 7 8 9 10
Option 3 Infinite Loop
Option 4 5 6 7 8 9 10
Option 5
Question Difficulty Level Bloom’s
Metadata Taxonomy
Easy Apply

You might also like