Latest C & Data Structures Interview Questions part 1

What Is C Language?
C is a programming language used to write a program. Programs are the set of instructions given by a programmer to the computer in high level language. C uses a compiler to translate the high level program into machine code before executing any instruction.
What Does Static Variable Mean?
Static variable is available to a C application, throughout the life time. At the time of starting the program execution, static variables allocations takes place first. In a scenario where one variable is to be used by all the functions (which is accessed by main () function), then the variable need to be declared as static in a C program.
What Is The Difference Between Calloc() And Malloc() ?
A block of memory may be allocated using the function malloc. The malloc function reserves a block of memory of specified size and returns a pointer of type void. This means we can assign the base address of the block to any type of pointer.
Syntax – P = (cast type*)malloc(byte size);
Calloc is also a memory allocation function which is generally used to allocate memory for array and structure .malloc is used to allocate a single block of storage space, calloc allocates multiple blocks of storage, each of same size and initializes them with zero.
Syntax – P = (cast type*)calloc(n,array size);
What Is A Null Pointer?
A null pointer is a special pointer value that is known not to point anywhere. It means that no other valid pointer, to any other variable or array cell or anything else, will ever compare equal to a null pointer.
Advantages Of A Macro Over A Function?
Actually macro and function are used for different purposes. A macro replaces its expression code physically in the code at the time of preprocessing. But in case of function the control goes to the function while executing the code. So when the code is small then it is better to use macro. But when code is large then function should be used.
What Is Page Thrashing?
It happens when a high level of paging activity. Thrashing is caused by under allocation of minimum number of pages required by a process, forcing it to continuously page fault.
How Do You Override A Defined Macro?
You can use the #undef preprocessor directive to undefined (override) a previously defined macro.
What Are The Different Storage Classes In C?
C has three types of storage: automatic, static and allocated. Variable having block scope and without static specifier have automatic storage duration. Variables with block scope and with static specifier have static scope. Global variables (i.e., file scope) with or without the static specifier also have static scope. Memory obtained from calls to malloc(), alloc() or realloc() belongs to storage class.
When Does The Compiler Not Implicitly Generate The Address Of The First Element Of An Array?
Whenever an array name appears in an expression such as
• Array as an operand of the sizeof operator.
• Array as an operand of “&” operator.
• Array as a string literal initializer for a character array.
Then the compiler does not implicitly generate the address of the address of the first element of an array.
Is Using Exit () The Same As Using Return?
No, The exit () function is used to exit your program and return control to the operating system.The return statement is used to return from a function and return control to the calling function. If you issue a return from the main () function, you are essentially returning control to the calling function, which is the operating system. In this case, the return statement and exit () function are similar.
What Do You Mean By Dynamic Memory Allocation? Give An Example.
The process of allocating memory at the time of execution is called dynamic memory allocation. The allocation and release of this memory space can be done with the help of some built in functions whose prototypes are found in alloc.h and stdlib.h.
How Do You Construct An Increment Statement Or Decrement Statement In C?
There are actually two ways you can do this. One is to use the increment operator ++ and decrement operator –. For example, the statement “x++” means to increment the value of x by 1. Likewise, the statement “x –” means to decrement the value of x by 1.
Another way of writing increment statements is to use the conventional + plus sign or – minus sign. In the case of “x++”, another way to write it is “x = x +1”.
What Is The Difference Between Call By Value And Call By Reference?
When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.
Some Coders Debug Their Programs By Placing Comment Symbols On Some Codes Instead Of Deleting It. How Does This Aid In Debugging?
Placing comment symbols /* */ around a code, also referred to as “commenting out”, is a way of isolating some codes that you think maybe causing errors in the program, without deleting the code.
The idea is that if the code is in fact correct, you simply remove the comment symbols and continue on. It also saves you time and effort on having to retype the codes if you have deleted it in the first place.
What Is A Stack?
A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out) approach. At any particular instance, only the top of the stack is accessible, which means that in order to retrieve data that is stored inside the stack, those on the upper part should be extracted first. Storing data in a stack is also referred to as a PUSH, while data retrieval is referred to as a POP.
What Is A Sequential Access File?
When writing programs that will store and retrieve data in a file, it is possible to designate that file into different forms. A sequential access file is such that data are saved in sequential order: one data is placed into the file after another. To access a particular data within the sequential access file, data has to be read one data at a time, until the right one is reached.
What Is Variable Initialization And Why Is It Important?
This refers to the process wherein a variable is assigned an initial value before it is used in the program. Without initialization, a variable would have an unknown value, which can lead to unpredictable outputs when used in computations or other operations.
What Is Spaghetti Programming?
Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the program. This unstructured approach to coding is usually attributed to lack of experience on the part of the programmer. Spaghetti programing makes a program complex and analyzing the codes difficult, and so must be avoided as much as possible.
Differentiate Source Codes From Object Codes
Source codes are codes that were written by the programmer. It is made up of the commands and other English-like keywords that are supposed to instruct the computer what to do. However, computers would not be able to understand source codes.
Therefore, source codes are compiled using a compiler. The resulting outputs are object codes, which are in a format that can be understood by the computer processor. In C programming, source codes are saved with the file extension .C, while object codes are saved with the file extension .OBJ
In C Programming, How Do You Insert Quote Characters (‘ And “) Into The Output Screen?
This is a common problem for beginners because quotes are normally part of a printf statement. To insert the quote character as part of the output, use the format specifiers ’ (for single quote), and ” (for double quote).
What Is The Use Of A ‘’ Character?
It is referred to as a terminating null character, and is used primarily to show the end of a string value.
What Is The Difference Between The = Symbol And == Symbol?
The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other hand, the == symbol, also known as “equal to” or “equivalent to”, is a relational operator that is used to compare two values.
What Is The Modulus Operator?
The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol. For example: 10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.
What Is A Nested Loop?
A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop that is inside an outer loop. In this scenario, the inner loop is performed a number of times as specified by the outer loop. For each turn on the outer loop, the inner loop is first performed.

Related

Interview Questions 4517766356405860128

Post a Comment

emo-but-icon

item