C Interviews
C Interview
Now that we have written a few programs let us look at the instructions that we used in these programs. There are basically three types of instructions in C : ? Type Declaration Instruction ? Arithmetic Instruction ? Control Instruction
The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.
Pointer is used in the following cases ? It is used to access array elements. ? It is used for dynamic memory allocation. ? It is used in Call by reference. ? It is used in data structures like trees, graph, linked list etc.
The function main() invokes other functions within it.It is the first function to be called when the program starts execution. ? It is the starting function. ? It returns an int value to the environment that called the program. ? Recursive call is allowed for main( ) also. ? It is a user-defined function.
#include? ? ----> Specifically used for built in header files. #include ? ? ----> Specifically used for used for user defined/created n header file.
? It reduces the Complexity in a program by reducing the code. ? Function are easily understanding and reliability and execution is faster. ? It also reduces the Time to run a program.In other way,Its directly proportional to Complexity. ? Its easy to find-out the errors due to the blocks made as function definition outside the main function.
We can declare an array by specify its data type, name and the number of elements the array holds between square brackets immediately following the array name. syntax : data_type array_name[size];
Array is collection of similar datatype. it is a static memory allocation means we can not increment and decrement the arry size once we allocated. and we can not increment the base address, reassign address. Pointer is a dynamic memory allocation. we can allocate the size as we want, assigning into another variable and base address incrementation is allowed.
The strcpy() function is designed to work exclusively with strings. It copies each byte of the source string to the destination string and stops when the terminating null character () has been moved. On the other hand, the memcpy() function is designed to work with any type of data. Because not all data ends with a null character, you must provide the memcpy() function with the number of bytes you want to copy from the source to the destination.
Null pointer is a pointer that is pointing nothing while NULL macro will used for replacing 0 in program as #define NULL 0 .