
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. | Which of the following cannot be checked in a switch-case statement? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: 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.
The value of the 'expression' in a switch-case statement must be an integer, char, short, long. Float and double are not allowed. Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
2. | Point out the error, if any in the program.
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Variable b is not assigned. It should be like: Learn more problems on : Control Instructions Discuss about this problem : Discuss in Forum |
3. | Which of the following statements are correct about the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: This program will result in error "Statement missing ;" printf("x is less than y\n") here ; should be added to the end of this statement. 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: Step 1: int i=4, j=-1, k=0, w, x, y, z; here variable i, j, k, w, x, y, z are declared as an integer type and the variable i, j, k are initialized to 4, -1, 0 respectively. Step 2: w = i || j || k; becomes w = 4 || -1 || 0;. Hence it returns TRUE. So, w=1 Step 3: x = i && j && k; becomes x = 4 && -1 && 0; Hence it returns FALSE. So, x=0 Step 4: y = i || j &&k; becomes y = 4 || -1 && 0; Hence it returns TRUE. So, y=1 Step 5: z = i && j || k; becomes z = 4 && -1 || 0; Hence it returns TRUE. So, z=1. Step 6: printf("%d, %d, %d, %d\n", w, x, y, z); Hence the output is "1, 0, 1, 1". Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
5. | Are the following two statement same?
|
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: No, the expressions 1 and 2 are not same. 1. a <= 20 ? (b = 30) : (c = 30); This statement can be rewritten as,
2. (a <=20) ? b : (c = 30); This statement can be rewritten as,
Learn more problems on : Expressions Discuss about this problem : Discuss in Forum |
6. | Macros have a local scope. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file. Learn more problems on : C Preprocessor Discuss about this problem : Discuss in Forum |
7. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Learn more problems on : Pointers Discuss about this problem : Discuss in Forum |
8. | Is this a correct way for NULL pointer assignment? |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The correct way is char *q=0 (or) char *q=(char*)0 Learn more problems on : Pointers Discuss about this problem : Discuss in Forum |
9. | What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Step 1: int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; The array a[3][4] is declared as an integer array having the 3 rows and 4 colums dimensions. Step 2: printf("%u, %u\n", a+1, &a+1); The base address(also the address of the first element) of array is 65472. For a two-dimensional array like a reference to array has type "pointer to array of 4 ints". Therefore, a+1 is pointing to the memory location of first element of the second row in array a. Hence 65472 + (4 ints * 2 bytes) = 65480 Then, &a has type "pointer to array of 3 arrays of 4 ints", totally 12 ints. Therefore, &a+1 denotes "12 ints * 2 bytes * 1 = 24 bytes". Hence, begining address 65472 + 24 = 65496. So, &a+1 = 65496 Hence the output of the program is 65480, 65496 Learn more problems on : Arrays Discuss about this problem : Discuss in Forum |
10. | The library function used to reverse a string is |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: strrev(s) Reverses all characters in s Example:
Output: Before strrev(): IndiaBIX After strrev(): XIBaidnI Learn more problems on : Strings Discuss about this problem : Discuss in Forum |
11. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Strings Discuss about this problem : Discuss in Forum |
12. | What will be the output of the program ?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Learn more problems on : Structures, Unions, Enums Discuss about this problem : Discuss in Forum |
13. | Point out the error in the program?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: This type of declaration is called as self-referential structure. Here *e is pointer to a struct emp. Learn more problems on : Structures, Unions, Enums Discuss about this problem : Discuss in Forum |
14. | On declaring a structure 0 bytes are reserved in memory. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Structures, Unions, Enums Discuss about this problem : Discuss in Forum |
15. | On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The file source.txt is opened in read mode and target.txt is opened in write mode. The file source.txt contains "To err is human". Inside the while loop, ch=getc(fs); The first character('T') of the source.txt is stored in variable ch and it's checked for EOF. if(ch==EOF) If EOF(End of file) is true, the loop breaks and program execution stops. If not EOF encountered, fseek(fs, 4L, SEEK_CUR); the file pointer advances 4 character from the current position. Hence the file pointer is in 5th character of file source.txt. fputc(ch, ft); It writes the character 'T' stored in variable ch to target.txt. The while loop runs three times and it write the character 1st and 5th and 11th characters ("Trh") in the target.txt file. Learn more problems on : Input / Output Discuss about this problem : Discuss in Forum |
16. | What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Here argv[1], argv[2] and argv[3] are string type. We have to convert the string to integer type before perform arithmetic operation. Example: j = atoi(argv[1]) + atoi(argv[2]) + atoi(argv[3]); Learn more problems on : Command Line Arguments Discuss about this problem : Discuss in Forum |
17. | In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision? |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Yes you have to compile a program like tcc myprog wildargs.obj Learn more problems on : Command Line Arguments Discuss about this problem : Discuss in Forum |
18. | Bitwise | can be used to multiply a number by powers of 2. |
|||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Bitwise Operators Discuss about this problem : Discuss in Forum |
19. | What do the following declaration signify?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Complicated Declarations Discuss about this problem : Discuss in Forum |
20. | What will be the output of the program under DOS?
|
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Learn more problems on : Complicated Declarations Discuss about this problem : Discuss in Forum |