If you are a Computer Science student, you must have heard about C programming language or may have had some experience with this language. Obviously, it is important for every programming student that they must be aware of C language because it is the building blocks of many popular programming languages such as C++, C#, Java, and Python. If you have mentioned C language with your other skills in your Resume, when you are going to appear for an interview you must be sure that you are acquainted of all the basic and easy concepts of C language including the tough one too. Here we have selected Top 25 Questions of C language which are mostly asked during the interviews.

 

  • Who is the creator of the C programming language?

 

Dennis Ritchie invented the C programming language at Bell Labs.

 

  • Give some key Features of C.

 

  • It is portable that means code written on one computer can run on other computers.
  • It comes with a feature called Modularity which can break the programs into small modules.
  • The compiling speed of C language is very high due to its Procedural Concept.
  • Code security is also good.

 

  • What break keyword do in C?

 

Keyword break is used to break a loop or switch statement, so that the and walk out from it.

 

  • How many reserved keywords C have?

 

32

 

  • What is the full form of ASCII?

 

American Standard Code for Information Interchange.

 

  • What is the default value of int static variable?

 

0

 

  • How \(backslash) use in printf()?

 

\(backslash) use in escaping.

e.g.

printf(“hello \n world);

//output

hello

world

 

  • Are N++ and N+1 take the same time to execute, if not why?

 

No, N++ and N+1 do not take the same time to execute. N++ can execute faster than N+1 because the N++ statement run in a single instruction, but N+1 take more operation to perform.

 

  • Give some difference between local and global variable.

 

Local variables are declared inside the function, whereas global variable declares outside the function.

Only that function can access the local variable which had declared it, however, any function can use the global variable.

 

  • What is a pointer on a pointer?

 

A pointer variable that contains the address of another pointer variable.

e.g.

int **pointer

 

  • What is a base address of an array?

 

The first element address of the array is known as the base address, and with the help of base address we can find the address of the consecutive array elements.

 

  • Does main() function require to compile a program?

 

No program can be compiled without the main() function, and it won’t execute.

 

  • What is a structure in C?

 

A structure is a data structure in C which is a collection of heterogeneous data items.

 

  • what is prefixed increment?

 

In prefixed increment, the value of the variable increase first.

e.g.

int a=0;

++a   // increment operation.

 

  • How dynamic data structure in C is efficient as compared to the static data structure?

 

The dynamic data structure shows their efficiency in memory allocation, which is the main asset of dynamic data structure over the static data structure. In the dynamic data structure, the memory access only occurs when it’s needed, which prevent from memory wastage.

 

  • Can we create a new header file?

 

Yes.

 

  • What is a dangling pointer?

 

A dangling pointer is a pointer to storage that is no longer allocated. For example, when a pointer is pointing a memory address of a variable, but when the variable is deleted and the pointer is still pointing the memory location this pointer will be termed as a dangling pointer.

 

  • What typedef keyword do in C?

 

typedef keyword is used to give an alternate name to a reserved datatype keyword.

e.g.

typedef unsigned char ch;                 // now ch has become a char data type

ch string1[20], string2[30];

 

  • What are modifiers? Name some of the modifier used in C.

 

Modifiers are the prefix of a datatype which is used to modify the memory allocation of the datatype.

e.g.

long int a; //here long is a modifier and the “a”will occupy 8 bits of space in the memory.

Short int b;// short is the modifier and “b” will occupy 2 bit of space in the memory

Modifiers:

  1. short
  2. long
  3. unsigned
  4. signed

 

  • What is typecasting in C?

 

A typecasting is a method in C which can convert the data type of a variable into another data type.

e.g.

float a;

int b = (int) a;          // type casting from float to int

printf(“%d”, b);

 

  • What is an Infinite loop?

 

When a loop run continuously for infinite time or the loop statement never get false is known as infinite loop.

e.g.

int a =1;

while(a==1)

{ printf(“run infinite time”);

}

 

  • what malloc() and calloc() function do?

 

Both malloc () and calloc () perform the same function, which is they provide dynamic memory allocation to a variable.

malloc() use to reserve a single block of memory and return a pointer where as calloc() is used to allocates multiple block of memory.

// malloc() and calloc() syntax

Mptr = (int*) malloc(20*sizeof(int));

Cptr= (int*) calloc(20, sizeof(int));

 

  • What is a NULL pointer?

 

Many times we require a pointer to points nothing that time we use NULL pointer. A NULL pointer is that pointer which points to nothing. The NULL pointer mostly used in the linked list.

 

  • Name the function used to convert a string to a Number.

 

1 atof(): convert a string to a float

2 atoi(): convert a string to an integer

3 atol(): convert a string to a long integer.

 

  • What is #pragma?

 

The #pragma is a preprocessor directive that allows each compiler to implement compiler-specific features that can be turned on and off by using the #pragma statement.

Leave a Reply

Your email address will not be published. Required fields are marked *