About Me

Hello there! Before talking about qualifications and professional abilities, I would like to introduce myself. I am a Yuvraj Basnet and professional software developer and have been working in this field for 3 long years. I have finished my graduation from The University of Delhi on Computer Science Engineering I considered myself a reasonably experienced programmer with a particular interest in the human side of software development, computers are fascinating machine, but they're mostly reflection of the people using them. In the art of software development, studying code isn't enough; you have to study the people behind the software, too.

Beginner Level Interview Questions and Answers

basic interview Question, Beginner- Level-Interview-Questions-and Answers

Beginner Level Interview Questions and Answers

Hi there! In the previous article we discussed about what is Recursion in C language now in this article we will discuss some important Beginner Level Questions and Answers which is asked by the interviewer at the time of interview.
So, without wasting further any time let's get started.

Question 1. What are the Basic Data types supported in C language?


Basic Datatypes Supported in C language

1. Int Datatype:

Integers are whole numbers that can have both positive and negative values, but it doesn't contain decimal values.

The size of the int is 2 byte

for example- 0, -10, 10

Programmers use int type for declaring an integer variables
int age;  (Here, age is a variable of type integer)

2. Float Datatype:
Programmers use float datatype to hold the real and decimal number.
for example- 20.45, -20.34 etc.
float salary; (Here, salary is a variable of type float)
The size of the float is 4 byte.

3. Char Datatype:
Programmers use char datatype to for declaring character type variables.
for example- ch etc
char ch='y'; (Here, ch is the variable of char type and contain the character y in single quote)
The size of the character type is 1 byte.

Question 2. What do you mean by pointer variable?

Answer- pointer is a variable that stores the address of another variable. Unlike other variables that hold values of a certain type, pointer holds the address of a variable. For example, an float variable holds float value, however an floating pointer holds the address of a floating variable.

Syntax: int* ptr;
Here, we declared the pointer ptr of integer type.

We can also declared the pointers in the following ways:
int *ptr1;
int * ptr2;

let's take some example of declaring pointers
int* ptr1, ptr2;
Here, we have declared the pointer variable ptr1 and a normal variable of type int.

Addressing addresses to the pointers
Example- int* ptr1, ptr2;
                    ptr2= 10;
                    ptr1= &ptr2;
Here, 10 is assigned to the ptr2 variable and the address of ptr2 is assigned to the ptr1 pointer.

Question 3. What are static variables?

Answer- Static variable have a property of preserving their value even after they are out of their scope.
Some points related to the static variables:

  • Static Variables are declared inside or outside the functions.
  • The default value of static variable is always 0.
  • Lifetime of static variables are till the determination of program.
  • Static Variables must be declared with keyword static.
  • It is created only for the first function call same variable is used for subsequent call.
  Syntax: static datatype variable_name = value;

1 1

Question 4. What are functions in C?

Answer- Function: 
The function contains the set of codes or statements enclosed by curly braces({}). A function can be called more than one time to provide reusability and modularity to the programs. 

Function Aspect:

Two types of functions in C programming:

1. Library Functions: Library functions are the functions which are declared in the C header files  such as scanf(), printf(), gets(), puts(), ceil(), floor() etc.

2. User-defined functions: User-defined functions are the functions which are created by the C programmer, so that he/she can use it many times. It reduces the complexity of a big program and optimizes the code.

      Question 5. Differentiate between Calloc( ) and Malloc( )?
  • Calloc( ) stands for Contiguous allocation whereas Malloc stands for Memory allocation.
  • It's allocates a multiple block of memory of same size whereas It's allocates a single block of memory of specified size.
  • The Calloc( ) contains two arguments i.e, elements and size of each memory whereas The Malloc( ) contain one argument i.e, size of datatype.
  • It initializes the allocated memory with zero whereas It initializes the allocated memory with garbage value.
  • It is slower than malloc( ) whereas It is faster than Calloc( ).
Question 6. When we use break control statement?

  • Whenever a break statement is encountered inside a loop, the control directly comes out of loop terminating it. It is used along with if statement, whenever used inside loop so that it occurs only for a particular condition.
  • It is used in switch case control structure after the case blocks. Generally all cases in switch case are followed by a break statement to avoid the subsequent cases execution. Whenever it is encountered in switch-case block, the control comes out of the switch-case body.
Question 7. How the negative numbers are stored in memory?

Answer- Computer uses special mechanism to store negative integers which is 
called 2's complement format.

Let's have a look on 1's complement of a number

1's complement of a number:
Inverting binary bits of an actual number is called 1's complement of number.

  • Example- 
          10 Binary representation will be (1010)2
                1's complement of 10 is 0101 (switching 0 to 1 and 1 to 0).

2's complement of a number:
To get 2’s complement of a number, just add 1 to 1’s complement of an actual number.

Pictorial Representation:

- This 2's complement form will be stored in a memory.

Question 8. Difference between formal and actual parameters?


  • An ordered list of parameters which are included at the time of definition of function whereas These are ordered list of parameters which are included at the time of function call.
  • Data types needs to be mentioned whereas Data type not required. But data type should match with corresponding data type of formal parameters.
  • These are variables with their data type whereas These can be variables, expression and constant without data types.
  • These are only definition of inputs data types. These are to shows which type of data should be given as input while calling the function whereas These are actual values which are given as input to the called function.
Question 9. What is Nested Structure?

Answer- When a data member of one structure is referred by the data member of another function, then the structure is called as Nested Structure.

Question 10. What is a C Token?

Answer- C Token may be defined as a smallest individual unit of the program.
There are six token in C language:

i. Keywords- Keywords are the reserved words or predefined words whose meaning is already known to the compiler.

  • 32 keywords defined by C89.
  • Examples- int, float, void etc.
ii. Identifiers- Identifiers are the name given to the variables, constants, functions and user-defined data.
  • Examples- int a, float b, etc.
iii. Constant- Constant are those quantities whose value are fixed and can not be changed during the runtime.
  • Examples- 1,2;
  • Const int a =5 etc
  • Here, value of variable of a is 5 which is constant.
iv. Strings- String is actually a one dimensional array of characters which is terminated by a null character i.e, '\0'.
  • Examples- chat ch[ ]= "Hello";
v. Operators- An operator is a symbol that tells the compiler to perform specific mathematical or logical operation.
  • Examples- +, -, &&, etc
vi. Punctuators- Punctuators separate two statements like ';' describes the end of a statement. They are also also known as separators.
  • Examples- [], (), {},# etc.
Question 11. What is PreProcessor ?

Answer- A Preprocessor Directive is considered as a built in predefined function that acts as a directive to the computer and it gets executed before the actual source program is executed.

Question 12. Why C is called Mother of all computer languages?

Answer- C is known as a mother language because most of the compilers and JVMs are written in C language. Most of the languages which are developed after C language has borrowed heavily from it like C++, Python, Rust, javascript, etc. It introduces new core concepts like arrays, functions, file handling which are used in these languages.

Question 13. What is the use of printf() and scanf()?

Answer- printf() is used to print the values on the screen. To print certain values, and on the other hand, scanf() is used to scan the values entered by the user. We need an appropriate datatype  format specifier for both printing and scanning purposes.

Question 14. What is '\0' Character?

Answer- The symbol mentioned is called a Null Character. It is considered as a terminating character used in strings to notify the end of the string to the compiler.

Question 15. Differentiate  between compiler and interpreter?

  • A compiler translate the complete source program in a single run whereas An interpreter translates the source program line by line.
  • It consumes less time whereas It consumes more time than compiler.
  • It is faster whereas It is slower.
  • The error localization is difficult whereas The error localization is easier than compiler.
  • CPU utilization is more whereas CPU utilization is less compare to compiler.
  • Both syntactic and semantic errors can be checked at the same time whereas Only semantic error can checked at a time.
  • A presence of an error may cause whole program to be reorganized whereas A presence of error causes only a part of the program to be reorganized.
  • Compiler is used by languages such as C, C++ etc whereas An interpreter is used by languages such as Java etc.


Post a Comment