top of page
Anchor 1
Frequently Asked C Interview Question & Answers

What do you mean by #include<stdio.h>?

In C, the hash function # tells the compiler that a statement should be sent to the C preprocessor. The 'include' looks after the new files and replace the contents of those files. and stdio.h will be valid only for the printf, scanf functions.

Close

What is a pointer?

A pointer is a special variable, which stores the memory address. The ‘ampersand’ denoted by ‘&’ and the ‘dereferencing’ factor denoted by ‘*’ are the necessities of pointers. Ampersand in front of a variable gets its address and asterisk in front of a pointer gets its value.

Close

Where the function pointers can be used?

The function pointers can be used when if/switch statements are present, in late binding(variation tables) and to implement callbacks activities.

Close

What is null pointer?

A Null pointer is a pointer which cannot point to anywhere in the program, but uninitialised pointer can point to anywhere in the users' program. In C, if the pointer tried to access 0th location, the operating system kills the running program because the operating system does not allow to access 0th value.

Example :

  • Integer pointer : int *ptr=(char *);

  • Float Pointer : float *ptr=(float *);

  • Character Pointer : char *ptr=(char *);

Close

Define function pointer?

The function pointer is the pointer which accesses the address of a function. The running program occupies some memory space. Both the executable compiled program code and as well as user variables work on function pointers.
In the C, each function has an address in a code segment.

Close

Compare between array and pointer.

An array can allocate variables but cannot reallocate those variable if required.  Whereas the pointer was assigned to allocate variables and they can also relocate and also are resizable.

Close

Define function prototype?

The function prototype is the prototype which depends on the following:

  • No. of input types

  • No. of outputs which are to be returned

Close

What is volatile variable?

Volatile variables are those variables which alter the default way of the program.
The variable which does not change while compiling but are changeable during execution.

Close

Difference between global and static variable?

Static variables persist throughout the scope, but the lifespan is not throughout the program. Global variables persist throughout the scope of base blocks of memory that is their lifespan is throughout the program.

Close

What are the files automatically opened when C file is executed?

Standard in, standard out, standard error (stdin, stdout, stderr) are the files which are automatically opened when C file is executed.

Close
bottom of page