C Interview questions

WHAT ARE DIFFERENT TECHNIQUES FOR MAKING HASH FUNCTION?

Techniques for making hash function.
• Truncation Method
This is the simplest method for computing address from a key.In this method we take only a part of the key as address.
• Midsquare Method
In this method the key is squared and some digits from the middle of this square are taken as address.
• Folding Method
In this technique, the key is divided into different part where the length of each part is same as that of the required address, except possibly the last part.
• Division Method (Modulo-Division)
In Modulo-Division method the key is divided by the table size and the remainder is taken as the address of the hash table.
–>Let the table size is n then
H (k) =k mod n
Master C and Data Structure, in this C and Data Structure certification training.

WHAT ARE THE ISSUES THAT HAMPER THE EFFICIENCY IN SORTING A FILE?

The issues are:
  • Length of time required by the programmer in coding a particular sorting program.
  • Amount of machine time necessary for running the particular program.
  • The amount of space necessary for the particular program.

WHAT IS THE USE OF VOLATILE KEYWORD?

The modifier ‘volatile’ tells the compiler that a variable’s value may be changed in ways not explicitly specified by the program. For example, a global variable’s address may be passed to the operating system’s clock routine and used to hold the system time.
In this situation, the contents of the variable are altered without any explicit assignment statements in the program.
This is important because most C compilers automatically optimize certain expressions by assuming that a variable’s content is unchanging if it does not occur on the left side of an assignment statement. Thus, it may not be reexamined each time it is referenced. Also, some compilers change the order of evaluation of an expression during the compilation process. The volatile modifier prevents these changes.

WRITE A C PROGRAM WITHOUT USING SEMICOLON TO PRINT ‘HELLO WORLD’

void main(){
if(printf(“Hello world”)){
}
}

WHAT ARE DIFFERENCES BETWEEN SIZEOF OPERATOR AND STRLEN FUNCTION?

sizeof is keyword of C that can find size of a String constant including null character, but strlen is function which has been defined string.h and can find number of characters in a string excluding null character.
#include
void main(){
int a,b;
a=strlen(“cquestionbank”);
b=sizeof(“cquestionbank”);
printf(“%d  %d”,a,b);
getch();
}

WHAT IS THE DIFFERENCE BETWEEN

sprintf(…) writes data to the character array. The C library function sprintf () is used to store formatted data as a string. You can also say the sprintf () function is used to create strings as output using formatted data. The syntax of the sprintf () function is as follows:
int sprintf (char *string, const char *form, … );
Here, the *string will stand for the name of the array that will store the output obtained by working on the formatted data. The *form parameter will show the format of the output.
printf(…) writes data to the standard output device. The printf function is just a useful function from the standard library of functions that are accessible by C programs.
The behavior of printf is defined in the ANSI standard. If the compiler that you’re using conforms to this standard then all the features and properties should be available to you.

WHEN DOES THE COMPILER NOT IMPLICITLY GENERATE THE ADDRESS OF THE FIRST ELEMENT OF AN ARRAY?

The compiler does not implicitly generate the address of the first element of an array whenever an array name appears:
– as an operand of the sizeof operator
– as an operand of & operator
– as a string literal initialize for a character array

IS USING EXIT() THE SAME AS USING RETURN?

No, the exit() function is used to exit your program and return() controls the operating system.
The return statement is used to return from a function and return control to the calling function. If you make a return from the main() function, you are essentially returning control(operating system) to the calling function. In this case, the return statement and exit() function are similar.

WHAT IS AN LVALUE?

An lvalue is an expression to which a value can be assigned. The lvalue expression is located on the left side of an assignment statement whereas an rvalue is located on the right side of an assignment statement.
Each assignment statement must have an lvalue and an rvalue. The lvalue expression must refer a storable variable in memory. It cannot be a constant.

Comments

Popular posts from this blog

Best online training.

ARTIFICIAL INTELLIGENCE INTERVIEW QUESTIONS