

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. |
Which of the declaration is correct? |
Answer» int length; denotes that variable length is int(integer) data type. char int; here int is a keyword cannot be used a variable name. int long; here long is a keyword cannot be used a variable name. float double; here double is a keyword cannot be used a variable name. So, the answer is int length;(Option A). | |
2. |
What is the output of the program? |
Answer» extern int a; indicates that the variable a is defined elsewhere, usually in a separate source code module. printf("%d\n", a); it prints the value of local variable int a = 20. Because, whenever there is a conflict between local variable and global variable, local variable gets the highest priority. So it prints 20. | |
3. |
What is the output of the program in Turbo C (in DOS 16-bit OS)? |
Answer» Any pointer size is 2 bytes. (only 16-bit offset) So, char *s1 = 2 bytes. So, char far *s2; = 4 bytes. So, char huge *s3; = 4 bytes. A far, huge pointer has two parts: a 16-bit segment value and a 16-bit offset value. Since C is a compiler dependent language, it may give different output in other platforms. The above program works fine in Windows (TurboC), but error in Linux (GCC Compiler). | |
4. |
What is the output of the program |
Answer» When an automatic structure is partially initialized remaining elements are initialized to 0(zero). | |
5. |
Which of the structure is incorrcet? |
Answer» Option B gives "Undefined structure in 'aa'" error. | |
6. |
Which of the structure is correct? |
Answer» In 2 and 3 semicolon are missing in structure element. | |
7. |
What is the output of the program given below ? |
Answer» enum takes the format like {0,1,2..) so pass=0, fail=1, atkt=2 stud1 = pass (value is 0) stud2 = atkt (value is 2) stud3 = fail (value is 1) Hence it prints 0, 2, 1 | |
8. |
A can be used if range of a is not enough to accommodate a real number. |
Answer» True, we can use long double; if double range is not enough. double = 8 bytes. long double = 10 bytes. | |
9. |
A is 4 bytes wide, whereas a is 8 bytes wide. |
Answer» True, float = 4 bytes. double = 8 bytes. | |
10. |
If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an declaration in the function. |
Answer» True, When a function is declared inside the source file, that function(local function) get a priority than the extern function. So there is no need to declare a function as extern inside the same source file. | |
11. |
Size of and can be verified using the operator. |
Answer» True, we can find the size of short integer and long integer using the sizeof() operator. Example: #include<stdio.h> int main() { short int i = 10; long int j = 10; printf("short int is %d bytes.,\nlong int is %d bytes.", sizeof(i),sizeof(j)); return 0; } Output: short int is 2 bytes. long int is 4 bytes. | |
12. |
Range of is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS) |
Answer» False, The range of double is -1.7e+308 to 1.7e+308. | |
13. |
Size of and would vary from one platform to another. |
Answer» True, Depending on the operating system/compiler/system architecture you are working on, the range of data types can vary. | |
14. |
Range of id -2.25e+308 to 2.25e+308 |
Answer» False, The range of float is -3.4e+38 to 3.4e+38. | |
15. |
When we mention the prototype of a function? |
Answer» A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function's name, argument types and return type. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface. | |
16. |
By default a real number is treated as a |
Answer» In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265... When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space. | |
17. |
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others. |
Answer» The only way this can be achieved is to define the variable locally in main() instead of defining it globally and then passing it to the functions which need it. | |
18. |
Is it true that a global variable may have several declarations, but only one definition? |
Answer» Yes, In all the global variable declarations, you need to use the keyword extern. | |
19. |
Is it true that a function may have several declarations, but only one definition? |
Answer» Yes, but the function declarations must be identical. Example: #include<stdio.h> void Display(); void Display(); void Display(); void Display() { printf("Weclome to IndiaBIX.com..!"); } int main() { Display(); return 0; } //Output: Weclome to IndiaBIX.com..! | |
20. |
What are the types of linkages? |
Answer» External Linkage-> means global, non-static variables and functions. Internal Linkage-> means static variables and functions with file scope. None Linkage-> means Local variables. | |
21. |
How would you round off a value from 1.66 to 2.0? |
Answer» /* Example for ceil() and floor() functions: */ #include<stdio.h> #include<math.h> int main() { printf("\n Result : %f" , ceil(1.44) ); printf("\n Result : %f" , ceil(1.66) ); printf("\n Result : %f" , floor(1.44) ); printf("\n Result : %f" , floor(1.66) ); return 0; } // Output: // Result : 2.000000 // Result : 2.000000 // Result : 1.000000 // Result : 1.000000 | |