-
-
-
Can a file other than a .h file be included with #include?
The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line #include <macros.inc> in your program, the file macros.inc will be included in your precompiled program. It is, however, unusual programming practice to put any file that does not have a .h or .hpp extension in an #include statement. You should always put a .h extension on...
-
-
-
Can the sizeof operator be used to tell the size of an array passed to a function?
No. There’s no way to tell, at runtime, how many elements are in an array parameter just by looking at the array parameter itself. Remember, passing an array to a function is exactly the same as passing a pointer to the first element.
-
How can I convert a string to a number?
The standard C library provides several functions for converting strings to numbers of all formats (integers, longs, floats, and so on) and vice versa. The following functions can be used to convert strings to numbers: Function Name Purpose atof() Converts a string to a double-precision floating-point value. atoi() Converts a string to an integer. atol() Converts a string to a long integer....
-
-
What would be the output of the following program? main() { int i=4; switch(i) { default: printf("n A mouse is an elephant built by the Japanese"); case 1: printf(" Breeding rabbits is a hair raising experience"); break; case 2: printf("n Friction is a drag"); break; case 3: printf("n If practice make perfect, then nobody's perfect"); } }
A) a) A mouse is an elephant built by the Japanese B) b) Breeding rabbits is a hare raising experience C) c) A mouse is an elephant built by the Japanese Breeding rabbits is a hare raising experienceD) d) None of the above
-
What is the stack?
The stack is where all the functions’ local (auto) variables are created. The stack also contains some information used to call and return from functions. A “stack trace” is a list of which functions have been called, based on this information. When you start using a debugger, one of the first things you should learn is how to get a stack trace. The stack is very inflexible about allocating memory;...
-
-
What is hashing?
To hash means to grind up, and that’s essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer. The idea behind hashing is that some data either has no inherent ordering (such as images) or is expensive to compare (such as images). If the data has no inherent ordering, you can’t perform...
-
-
-
-
-
What is the benefit of using const for declaring constants?
The benefit of using the const keyword is that the compiler might be able to make optimizations based on the knowledge that the value of the variable will not change. In addition, the compiler will try to ensure that the values won’t be changed inadvertently. Of course, the same benefits apply to #defined constants. The reason to use const rather than #define to define a constant is that a const variable...
-
-
-
C Interview Questions
Ans