Control Instructions Questions and Answers

Exercise

Exercise 1
Exercise 2

Article

Q 1

Which of the following cannot be checked in a switch-case statement?


A)   Character

B)   Integer

C)   Float

D)   enum


Correct Option - C

Explanation

The switch/case statement in the c language is defined by the language specification to use an int value, so you can not use a float value.


switch( expression )
{
    case constant-expression1:    statements 1;
    case constant-expression2:    statements 2;    
    case constant-expression3:    statements3 ;
    ...
    ...
    default : statements 4;
}

The value of the 'expression' in a switch-case statement must be an integer, char, short, long. Float and double are not allowed.

Report this question

Q 2

How many times "IndiaBIX" is get printed?

#include
int main()
{
    int x;
    for(x=-1; x10; x++)
    {
        if(x 5)
            continue;
        else
            break;
        printf("IndiaBIX");
    }
    return 0;
}

A)   Infinite times

B)   11 times

C)   0 times

D)   10 times


Correct Option - C

Explanation


Report this question

Q 3
In mathematics and computer programming, which is the correct order of mathematical operators ?

A) Addition, Subtraction, Multiplication, Division

B) Division, Multiplication, Addition, Subtraction

C) Multiplication, Addition, Division, Subtraction

D) Addition, Division, Modulus, Subtraction


Correct Option - B

Explanation

Simply called as BODMAS (Brackets, Order, Division, Multiplication, Addition and Subtraction).

Mnemonics are often used to help students remember the rules, but the rules taught by the use of acronyms can be misleading. In the United States the acronym PEMDAS is common. It stands for Parentheses, Exponents, Multiplication, Division, Addition, Subtraction. In other English speaking countries, Parentheses may be called Brackets, or symbols of inclusion and Exponentiation may be called either Indices, Powers or Orders, and since multiplication and division are of equal precedence, M and D are often interchanged, leading to such acronyms as BEDMAS, BIDMAS, BODMAS, BERDMAS, PERDMAS, and BPODMAS.

Report this question

Q 4
Which of the following is not logical operator?

A)   &

B)   &&

C)   ||

D)   !


Correct Option - A

Explanation

Bitwise operators:
& is a Bitwise AND operator.

Logical operators:
&& is a Logical AND operator.
|| is a Logical OR operator.
! is a NOT operator.

So, '&' is not a Logical operator.

Report this question

Q 5

How many times the while loop will get executed if a short int is 2 byte wide?

#include
int main()
{
    int j=1;
    while(j 255)
    {
        printf("%c %d\n", j, j);
        j++;
    }
    return 0;
}

A)   Infinite times

B)   255 times

C)   256 times

D)   254 times


Correct Option - B

Explanation

The while(j  loop will get executed 255 times. The size short int(2 byte wide) does not affect the while() loop.

Report this question


Share This Page -