
Instruction:
- This is a FREE online test. DO NOT pay money to anyone to attend this test.
- Total number of questions : 20.
- Time alloted : 30 minutes.
- Each question carry 1 mark, no negative marks.
- DO NOT refresh the page.
- All the best :-).
1. | Which of the following are unary operators in C?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: An operation with only one operand is called unary operation. && Logical AND is a logical operator. Therefore, 1, 2, 3 are unary operators. Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
2. | Which of the structure is correct?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: In 2 and 3 semicolon are missing in structure element. Learn more problems on : Declarations and Initializations Discuss about this problem : Discuss in Forum |
3. | Will the program compile successfully?
|
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Reports an error: Undefined symbol 'X' Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
4. | Assume integer is 2 bytes wide. What will be the output of the following code?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Memory Allocation Discuss about this problem : Discuss in Forum |
5. | Will the program outputs "IndiaBIX.com"?
|
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: No. It will print something like 'IndiaBIX(some garbage values here)' . Because after copying the first 8 characters of source string into target string strncpy() doesn't terminate the target string with a '\0'. So it may print some garbage values along with IndiaBIX. Learn more problems on : Library Functions Discuss about this problem : Discuss in Forum |
6. | Point out the error in the program
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: The conditional macro #if must have an #endif. In this program there is no #endif statement written. Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
7. | Can we use a switch statement to switch on strings? |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The cases in a switch must either have integer constants or constant expressions. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
8. | Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS) |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: False, The range of double is -1.7e+308 to 1.7e+308. Learn more problems on : Declarations and Initializations Discuss about this problem : Discuss in Forum |
9. | What will be the output of the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation:
Step 1: int x=4, y, z; here variable x, y, z are declared as an integer type and variable x is initialized to 4. Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
10. | Declare the following statement? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Complicated Declarations Discuss about this problem : Discuss in Forum |
11. | In the following code what is 'P'?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Typedef Discuss about this problem : Discuss in Forum |
12. | What will be the output of the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: for(i=1; i<=5; i++) Here the for loop runs 5 times.
Loop 1:
Loop 2: This above process will be repeated in Loop 3, Loop 4, Loop 5. Learn more problems on : Library Functions Discuss about this problem : Discuss in Forum |
13. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Step 1: char str1[20] = "Hello", str2[20] = " World"; The variable str1 and str2 is declared as an array of characters and initialized with value "Hello" and " World" respectively. Step 2: printf("%s\n", strcpy(str2, strcat(str1, str2))); => strcat(str1, str2)) it append the string str2 to str1. The result will be stored in str1. Therefore str1 contains "Hello World". => strcpy(str2, "Hello World") it copies the "Hello World" to the variable str2. Hence it prints "Hello World". Learn more problems on : Strings Discuss about this problem : Discuss in Forum |
14. | If the size of pointer is 4 bytes then What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Step 1: char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; The variable str is declared as an pointer to the array of 6 strings. Step 2: printf("%d, %d", sizeof(str), strlen(str[0])); sizeof(str) denotes 6 * 4 bytes = 24 bytes. Hence it prints '24' strlen(str[0])); becomes strlen(Frogs)). Hence it prints '5'; Hence the output of the program is 24, 5 Hint: If you run the above code in 16 bit platform (Turbo C under DOS) the output will be 12, 5. Because the pointer occupies only 2 bytes. If you run the above code in Linux (32 bit platform), the output will be 24, 5 (because the size of pointer is 4 bytes). Learn more problems on : Strings Discuss about this problem : Discuss in Forum |
15. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The function printf() returns the number of charecters printed on the console. Step 1: char a[] = '\0'; The variable a is declared as an array of characters and it initialized with "\0". It denotes that the string is empty. Step 2: if(printf("%s", a)) The printf() statement does not print anything, so it returns '0'(zero). Hence the if condition is failed. In the else part it prints "The string is empty". Learn more problems on : Strings Discuss about this problem : Discuss in Forum |
16. | If return type for a function is not specified, it defaults to int |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: True, The default return type for a function is int. Learn more problems on : Functions Discuss about this problem : Discuss in Forum |
17. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Note the below statement inside the struct: Learn more problems on : Structures, Unions, Enums Discuss about this problem : Discuss in Forum |
18. | Is it true that a function may have several declarations, but only one definition? |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Yes, but the function declarations must be identical. Example:
Learn more problems on : Declarations and Initializations Discuss about this problem : Discuss in Forum |
19. | What will be the output of the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The macro #define str(x) #x replaces the symbol 'str(x)' with 'x'. The macro #define Xstr(x) str(x) replaces the symbol 'Xstr(x)' with 'str(x)'. The macro #define oper multiply replaces the symbol 'oper' with 'multiply'. Step 1: char *opername = Xstr(oper); The varible *opername is declared as an pointer to a character type. => Xstr(oper); becomes, => Xstr(multiply); => str(multiply) => char *opername = multiply Step 2: printf("%s\n", opername); It prints the value of variable opername. Hence the output of the program is "multiply" Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
20. | 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. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: No, the carriage return tells the compiler to read the input from the buffer after ENTER key is pressed. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |