interview questions on c

Interview questions on c for freshers/beginners

What is c?who invented the c langauge?

C is a procedure oriented computer programming language,Which features economy expression,modern control flow,data structure and rich set of operators.it is invented by dennis ritchie in 1972 at bell and bell lab.

feature of c language?

.Extensive variety of operators and data types, to offer great range of options.

Modular in nature.

.c programs are portable can run on any compiler without modification.

.It is a powerful language as it provides a wide variety of data types and functions as well as control statements.

.Efficient use of pointer.

.It is very simple to write assembly language codes programss in c.

What ae the software and hardware requirements of c language?

Hardware requirements:-Pc with 512 kb base memory.

Software requirements:-c compiler.

Write a c program to print “hello world”?

#include<iostream.h> { printf(“hello world”); }

What are reserved words?

A reserved word is a type of c tokens also known as keywords.

Is there is any inbuilt input and output statement in c?

No, there is no inbuilt input/output statement in c.For input and output operations we use printf and scanf.

Why we use scanf in c?

We use scanf as a function to input data through the keyboard.

which function is used in c for printing “captions”?

Printf is used to print captions in c

why c called a middle level language?

As c is a combines the features of varous high level and low level languages so it is reffered as middle level language.

What is putchar?

Putchar is a function used to read a single character from the keyboard.

what is getchar?

Putchar is a function used for writting characters one at a time to the screen.
what are header files?

Header files provides definitions and declarations for library functions.E.g->math.h,conio.h etc.

Types of c compilers?

Turbo c,microsoft c, hisoft c,lattice c.

What are identifiers?

Variables,constatnts and functions are known by a common name called identifiers.

what are tokens ?

smallest individual units used in c programs known as tokens.

For e.g->If ,float,int,char,else,break,switch,continue etc.

How many types of c tokens are there in c’?

There are six types of ‘c tokens’ are there :-

.Keywords.

.Identifiers.

.constants.

.strings.

.special symbols.

.Operators.

primitive data types in c?

fundamental data types in c are as:-

data type range
char -128 to 127
int -32768 to 32767
float 3.4E-38 to 3.4e+38
double 1.7E-308 to 1.7E+308

what are constatnts?

Identifiers whose value is fixed during the execution of program known as constants.

e.g->int constants,float constants etc.

What are variables?

Variables are those whose value changes during the execution of program.

Types of variables?

Three types of variables:-

Automatic variable or internal variable.

Exteranl or global variable.

Static variable

If we do not include in our program then clrscr() will work or not ?

No, for clrscr() and getch() to work conio.h header file is required.

what is an expression?

Expression is a sequence of operand and operators which speicfy the compution of values.

Types of operators used in c?

OPerators used in c are as follows:-

.Arithmetic operators- e.g. Addition(+),multiplication(*),subtraction(-),Division(/).

.Relational operators- e.g. Less than(<), greater than(>),etc.

.logical operators- e.g. AND(&&),OR(||),NOT(!)

.assignment operators- e.g. Let a=2,b=3, then c=a+b=5.

.conditional opeators- e.g. If else statements etc.

.bitwise opeator- e.g. and(&),or(|),exclusive or(^),etc.

.Increment /decrement operatos- e.g. a++,a–,++a,–a.

.special operators- e.g. pointer,this pointer etc..

What is the use of goto function?

goto function is used to branch unconditionally from one point to another in a program,it requires a label to identify the place where the branch is to be made.

What is a while statement?

While statement is an entry control loop statement,when the contion is evaluated and the condition is true then the body of loop gets executed.
syntax:-while(condition) { body loop; }
How we can perform jump out of the loop ?

we can jump out of the loop by using break or goto statement.

why we use continue statement?

It is used to skip the part of body under certain condition.
syantax-continue;

what is an array?

An array is a collection of data of same type into a single variable. Types of arrays are:-

1. 1-d array

2. 2-d array

3. multidimensional array

what is a string?

A string is a collection of characters. There are alot types of string few names are as follows:-

.strlen- It is used to find the actual length length of the string.

.srtcpy- It is used to copy the string.

.strupr- it is used to convert the lower case alphabets to uppercase.

.strlwr- it is used to convert uppercase alphabets to lowercase. etc.

What is a function?

Collection of number of statements into a single logical unit known as function.

What is recursion?

When a function call itself within a function known as recursive function and the process is known as recursion.

Types of storage classes?

.Static

.register

.automatic

.external

What is a header file?
header files are the collection of definitions and declarations of library functions. Fog e.g->limits.h,stdlib.h,math.h,signal.h etc.
types of c instructions?

Constant declarartion.

Arithmetic instructions.

Control instructions.

list of I/o functions?

.scanf

.getchar

.printf

.getch

.gets

define.break?

Break statement force the loop to exit immedietly.

define.continue?

Continue loop instead of terminating the loop will skip the rest of the code in current block and will return to the evaluation part of the loop.

what is a nested loop?

A nested loop is a loop inside another loop.
for e.g->we use nested loop in diamond program.
List 5 library names with description?

Math.h———->contains math function used in c.

limits.h——–>define the boundaries of different types of data integers.

signal.h——–>conatins state functions.

stdio.h ——–>incorporate functions.

time.h ———>functions related to time and date.

write a hello program in clanguage?

#include

int main()

{

printf(“hello”);

}

what are global variables?

Global variables are those which can be accessed by every methods and functions within a program.

what are local variables?

local variables are those which are accessible by only that functions or methods in which they are defined.

diference between errors and debug?

Error:- error is a problem occured during creation of a program.

debug:- debug is the process of fixing the errors or problems.

Define.pointer?

A pointer is a variable that holds the memory address and represents location of data items such as variables .

define.This pointers?

This pointer is that pointer that holds the adress of the current variable.

what is a friend function?
A friend function is a function that is not a member of a class but has access to the class’s private and protected members.
types of errors in c?

There are following errors in c:-

1.compile time errors.

2.linker errors.

3.logical or virtual errors.

4.run time errors.

5.divide by 0.

6.value out of range

what are operators?
operators are the symbols that operated on a certain data types.
types of operators in c?

Types of operators in c are as follows:-

.arithmetic

.relational

.logical

.assignment

.conditional

.bitwise

what are unions?

Union is a data type with two or more members similar to structure but in union all members share common memory location.

what are stucts?

A struct or structure is a user defined data type,used to handle a group of logically related data items.

define.DMA?

Dynamic memory allocation is the practice of assigning memory locations to variables during execution of the program by explicit request of the programmer.

Deine.malloc,calloc,realloc and free with their syntax?

malloc:-Allocates memory to variable dynamically when requied.synatx->void malloc(size_tsize)

calloc:-allocates storage to a variable while the program is running.syntax->void calloc(size_tz,size_tsize)

realloc:-By using realloc we can change the size of the allocated area.syntax->void realloc(void*ptr,size_tsize)

free:-To release the reserverd area we will use free.syntax->void free(void*ptr)

41give some examples of symbolic constants?
Area of circle=pi*radius square
we cant have symbol of pi so we Use PI whose value is bydefault 3.14 replaced by the compiler when PI comes.

give some examples of keywords?

IF,while,do,break,continue etc.

how many types of statements used in c?

List of statements used in c are:-

If

switch

goto

while

do while

break

continue

if else etc.

which symbol is commonly used for making a statement comment?
// is used.
what is operator precedence?
operator precedence is used to perform complex calculations such that which operator will evaluate first.

How to take a screenshot

11 thoughts on “interview questions on c”

  1. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four
    e-mails with the same comment. Is there any way you can remove me
    from that service? Thanks a lot!

Placement prepration