Exercise: Control Instructions

Questions for: Control Instructions

The modulus operator cannot be used with a long double.
A:
True
B:
False
C:
D:
Answer: A

fmod(x,y) - Calculates x modulo y, the remainder of x/y.
This function is the same as the modulus operator. But fmod() performs floating point or long double divisions.

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
C:
D:
Answer: B

No, the carriage return tells the compiler to read the input from the buffer after ENTER key is pressed.

A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.
A:
True
B:
False
C:
D:
Answer: A

The basic C compiler is 16 bit compiler, below are the size of it's data types
The size of short int is 2 bytes wide(16 bits).
The size of long int is 4 bytes wide(32 bits).

Which of the following sentences are correct about a switch loop in a C program?
1: switch is useful when we wish to check the value of variable against a particular set of values.
2: switch is useful when we wish to check whether a value falls in different ranges.
3: Compiler implements a jump table for cases used in switch.
4: It is not necessary to use a break in every switch statement.
A:
1,2
B:
1,3,4
C:
2,4
D:
2
Answer: B
No answer description is available. Let's discuss.
Which of the following statements are correct about the below program?
#include<stdio.h>
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: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz