1.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.
2.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.
3.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.
4.Write a C program without using semicolon to print ‘Hello world’
5.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.
6.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.
7.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
8.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.
9.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.