Basic C Programming Interview Questions
Basic C Programming Interview Questions
calloc() is a dynamic memory allocation function that loads all the assigned memory
locations with 0 value.
2. What happens when a header file is included with-in double quotes ““?
When a header file in c++ is included in double-quotes, the particular header file is first
searched in the compiler’s current working directory. If not found, then the built-in
include path is also searched.
3. Define <stdio.h>.
When we want to restrict access to functions, we need to make them static. Making
functions static allows us to reuse the same function in C programming name in multiple
files.
Basic data types - Arithmetic data types, further divided into integer and floating-point
types
Derived datatypes -Arithmetic data types that define variables and assign discrete
integer values only
Void data types - no value is available
Enumerated data types -Array types, pointer types, function, structure and union types
The ‘==’ symbol or “equivalent to” or “equal to” symbol is a relational operator, i.e., it is
used to compare two values or variables.
#include <stdio.h>
void local_static()
static int a;
a= a + 1;
int main()
local_static();
local_static();
return 0;
01
Middle-Level Language - Combined form of both high level language and assembly
language
calloc() is a dynamic memory allocation function that loads all the assigned memory
locations with 0 value.
2. What happens when a header file is included with-in double quotes ““?
When a header file in c++ is included in double-quotes, the particular header file is first
searched in the compiler’s current working directory. If not found, then the built-in
include path is also searched.
3. Define <stdio.h>.
When we want to restrict access to functions, we need to make them static. Making
functions static allows us to reuse the same function in C programming name in multiple
files.
Basic data types - Arithmetic data types, further divided into integer and floating-point
types
Derived datatypes -Arithmetic data types that define variables and assign discrete
integer values only
Enumerated data types -Array types, pointer types, function, structure and union types
The ‘==’ symbol or “equivalent to” or “equal to” symbol is a relational operator, i.e., it is
used to compare two values or variables.
#include <stdio.h>
void local_static()
static int a;
printf("%d ", a);
a= a + 1;
int main()
local_static();
local_static();
return 0;
01
Middle-Level Language - Combined form of both high level language and assembly
language
As int is a part of standard C language library, and it is not possible to use it for any
other activity except its intended functionality, it is known as a reserved word.
if(n > 0)
display(n-1);
This is because, at any time, the values of the objects can be changed by code outside
the scope of the current code.
a=0;
while (a<=10) {
a++;
It is used as a prefix to primary data type to indicate the storage space allocation’s
modification to a variable. The available modifiers are:
1. short
2. long
3. long long
4. signed
5. unsigned
Pointers is a concept available in C and C++. The variable ‘v’ might contain the address
of another memory or a value.
9. What three parameters fseek() function require to work after the file is
opened by the fopen() function?
The number of bytes to search, the point of origin of the file, and a file pointer to the file.
10. Name a type of entry controlled and exit controlled loop in C programming.
Entry controlled loop- For loop (The condition is checked at the beginning)
Exit Controlled loop- do-while loop.[7] (The condition is checked in the end, i.e. loop
runs at least once
In the next section, we will go through some of the advanced interview questions on C
programming:
#include <stdio.h>
int main(void)
{
int *a = arr;
*a++;
return 0;
A block of memory previously allocated can be freed by using free(). The memory can
also be released if the pointer holding that memory address is: realloc(ptr,0).
The stack area is used to store arguments and local variables of a method. It stays in
memory until the particular method is not terminated.
The variable stores a value of num that has been first cast to an integer pointer and
then dereferenced.
Huge pointers are 32-bit pointers that can be accessed outside the segment, and the
segment part can be modified, unlike far pointers.
#include<stdio.h>
main()
char *a = "abc";
a[2] = 'd';
printf("%c", *a);
The program will crash as the pointer points to a constant string, and the program is
trying to change its values.
9. What is a union?
A union is a data type used to store different types of data at the exact memory
location.Only one member of a union is helpful at any given time.