
Instruction:
- This is a FREE online test. DO NOT pay money to anyone to attend this test.
- Total number of questions : 20.
- Time alloted : 20 minutes.
- Each question carry 1 mark, no negative marks.
- DO NOT refresh the page.
- All the best :-).
1. | How many times the while loop will get executed if a short int is 2 byte wide?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The while(j <= 255) loop will get executed 255 times. The size short int(2 byte wide) does not affect the while() loop. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
2. | Which of the following errors would be reported by the compiler on compiling the program given below?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Because, case 3 + 2: and case 5: have the same constant value 5. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
3. | Point out the error, if any in the program.
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The compiler will report the error "Constant expression required" in the line case P: . Because, variable names cannot be used with case statements. The case statements will accept only constant expression. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
4. | What will be the output of the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The order of evaluation of arguments passed to a function call is unspecified. Anyhow, we consider ++i, ++i are Right-to-Left associativity. The output of the program is 4, 3. In TurboC, the output will be 4, 3. In GCC, the output will be 4, 4. Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
5. | In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The equal to = operator has Right-to-Left Associativity. So it assigns b=5 then a=b. Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
6. | What is the notation for following functions?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: KR Notation means Kernighan and Ritche Notation. Learn more problems on : Functions Discuss about this problem : Discuss in Forum |
7. | How many times the program will print "IndiaBIX" ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing. A stack overflow occurs when too much memory is used on the call stack. Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error. Learn more problems on : Functions Discuss about this problem : Discuss in Forum |
8. | What will be the output of the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The macro function SQR(x)(x*x) calculate the square of the given number 'x'. (Eg: 102) Step 1: int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3. Step 2: a = SQR(b+2); becomes, => a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x . => a = 3+2 * 3+2; => a = 3 + 6 + 2; => a = 11; Step 3: printf("%d\n", a); It prints the value of variable 'a'. Hence the output of the program is 11 Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
9. | A preprocessor directive is a message from programmer to the preprocessor. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: True, the programmer tells the compiler to include the preprocessor when compiling. Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
10. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Pointers Discuss about this problem : Discuss in Forum |
11. | How will you free the allocated memory ? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Structures, Unions, Enums Discuss about this problem : Discuss in Forum |
12. | In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Declaration: char *fgets(char *s, int n, FILE *stream); fgets reads characters from stream into the string s. It stops when it reads either n - 1 characters or a newline character, whichever comes first. Therefore, the string str contain "I am a boy\n\0" Learn more problems on : Input / Output Discuss about this problem : Discuss in Forum |
13. | Which files will get closed through the fclose() in the following program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: Extra parameter in call to fclose(). Learn more problems on : Input / Output Discuss about this problem : Discuss in Forum |
14. | If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of below program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The file source.txt contains "Be my friend". fseek(fs, 0, SEEK_END); moves the file pointer to the end of the file. fseek(fs, -3L, SEEK_CUR); moves the file pointer backward by 3 characters. fgets(c, 5, fs); read the file from the current position of the file pointer. Hence, it contains the last 3 characters of "Be my friend". Therefore, it prints "end". Learn more problems on : Input / Output Discuss about this problem : Discuss in Forum |
15. | According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Command Line Arguments Discuss about this problem : Discuss in Forum |
16. | What will be the output of the program (myprog.c) given below if it is executed from the command line?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Command Line Arguments Discuss about this problem : Discuss in Forum |
17. | Point out the correct statement which correctly allocates memory dynamically for 2D array following program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Learn more problems on : Memory Allocation Discuss about this problem : Discuss in Forum |
18. | malloc() allocates memory from the heap and not from the stack. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Memory Allocation Discuss about this problem : Discuss in Forum |
19. | Point out the error in the following program.
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Learn more problems on : Variable Number of Arguments Discuss about this problem : Discuss in Forum |
20. | What do the following declaration signify?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Complicated Declarations Discuss about this problem : Discuss in Forum |