

InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
1. |
Point out the correct statements are correct about the program below? |
Answer» There are 2 errors in this program. 1. "Undefined symbol x" error. Here x is not defined in the program. 2. Here while() statement syntax error. | |
2. |
What will be the output of the program, if a is 2 bytes wide? |
Answer» for(i<=5 && i>=-1; ++i; i>0)so expression i<=5 && i>=-1 initializes for loop.expression ++i is the loop condition.expression i>0 is the increment expression. In for( i <= 5 && i >= -1; ++i; i>0) expression i<=5 && i>=-1 evaluates to one. Loop condition always get evaluated to true. Also at this point it increases i by one. An increment_expression i>0 has no effect on value of i.so for loop get executed till the limit of integer (ie. 65535) | |
3. |
Point out the error, if any in the program. |
Answer» switch(i) becomes switch(1), then the case 1: block is get executed. Hence it prints "Case1". printf("This is c program."); is ignored by the compiler. Hence there is no error and prints "Case1". | |
4. |
Point out the error, if any in the loop. |
Answer» The while() loop must have conditional expression or it shows "Expression syntax" error. Example: while(i > 10){ ... } | |
5. |
A is at least 16 bits wide and a is at least 32 bits wide. |
Answer» 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). | |
6. |
If is used to store a value in a variable then along with the value a carriage return(\r) also gets stored it. |
Answer» No, the carriage return tells the compiler to read the input from the buffer after ENTER key is pressed. | |
7. |
The modulus operator cannot be used with a . |
Answer» 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. | |
8. |
A char variable can store either an ASCII character or a Unicode character. |
Answer» Yes, we can store either an ASCII character or a Unicode character in a char variable. | |
9. |
The way the is used to take control out of and to take control of the beginning of the ? |
Answer» continue can work only with loops and not with switch | |
10. |
Can we use a statement to switch on strings? |
Answer» The cases in a switch must either have integer constants or constant expressions. | |
11. |
We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a ? |
Answer» We can do this in following switch statement switch(a) { case 2: case 3: case 4: /* some statements */ break; case 5: case 6: case 7: /* some statements */ break; } | |
12. |
By default, the data type of a constant without a decimal point is , whereas the one with a decimal point is a . |
Answer» 6 is int constant. 6.68 is double. 6.68L is long double constant. 6.68f is float constant. | |
13. |
How many times the loop will get executed if a is 2 byte wide? |
Answer» The while(j <= 255) loop will get executed 255 times. The size short int(2 byte wide) does not affect the while() loop. | |
14. |
In mathematics and computer programming, which is the correct order of mathematical operators ? |
Answer» 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. For more info: http://en.wikipedia.org/wiki/Order_of_operations | |