You are on page 1of 14

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.

net

Frequently Asked C Language Interview Questions and answers

1) Who invented C Language? Dennis Ritchie in 1972 developed a new language by inheriting the eatures o both !C"L and ! and adding additional eatures# $e na%ed the language as &ust C 2) Who invented ! Language? 'en (ho%son at )(*( !ell Labs developed a language and na%ed it !# +ven the ! language was ound to have so%e short co%ings to support develop%ent o both business applications and syste% so tware# ,) Who invented !C"L Language? !asic Co%bined "rogra%%ing Language-!C"L) was developed by .artin Richards/ Ca%bridge university# 0) Why C Language? C is one o the high level languages# 1t is a general purpose language/ which %eans it can be used to write progra%s o any sort# 2) What are the eatures o C Langauges?

1n C one can write progra%s li3e that o high level languages as in C4!4L/ !)51C/ 64R(R)7 etc# as well as it per%its very close interaction with the inner wor3ings o the co%puter# 1t is a general purpose progra%%ing language# 1t is usually called syste% progra%%ing language but e8ually suited to writing a variety o applications# 1t supports various data types 1t ollows the progra%%ing style based on unda%ental control low constructions or structured progra%%ing 6unctions %ay be pre9de ined or user de ined and they %ay return values o basic types/ structures/ unions or pointers#

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

:)What are the advantages o c language?


+asy to write Rich set o operators and unctions that are built9in 5upport or bit9wise operation 6le;ible use o pointers Direct control over the hardware )bility to access !145<D45 routines 1nteracting using 1nterrupts )bility to write (5R progra%s )bility to create #C4. iles )bility to create library iles -#L1!) )bility to write inter ace progra%s 1ncorporating asse%bly language in C progra%

7) What are the disadvantages o c language?


C is considered di icult to learn !ecause o its conciseness/ the code can be di icult to ollow 1t is not suited to applications that re8uire a lot o report or%atting and data ile %anipulation

=) What are the salient eatures o c languages?


(he ollowing are the salient eatures o C language are > C is called a %iddle level language C supports structured design approach C is e;tensible C is rich in data types and operators C is portable

9) What is a header ile? $eader iles provide the de initions and declarations or the library unctions# (hus/ each header ile contains the library unctions along with the necessary de initions and declarations# 6or e;a%ple/ stdio#h/ %ath#h/ stdlib#h/ string#h etc# 1?) What is character set? Character set is the set o characters allowed and supported in the progra%%ing language# @enerally a progra% is a collection o instructions/ which contain groups o characters# 4nly a li%ited set o characters is allowed to write instructions in the progra%# 11) What is C to3en?

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

(he s%allest individual units o a C progra% are 3nown as to3ens# 12) List the di erent types o C to3ens?

Constants 1denti iers 'eywords 4perators 5pecial sy%bols 5trings

1,) What is a string? ) string is a se8uence o characters ending with 7AL# 1t can be treated as a one9di%ensional array o characters ter%inated by a 7AL character# 10) What are 8uali iers? Buali iers or %odi iers are identi iers that %ay precede the scalar data types -e;cept loat) to speci y the nu%ber o bits used or representing the respective type o data in %e%ory# (he 8uali iers in C are short/ long/ signed/ and unsigned# 12) What is a unction? ) unction is a set o state%ents to per or% a speci ic tas3# 1:) What is a constant? ) constant is a value that does not change during the progra% e;ecution# ) constant used in C does not occupy %e%ory# 17) What are the di erent types o constants?

(here are ive types o constants# (hey are > 1nteger constants 6loating point constants Character constants 5tring literals +nu%eration constants

1=) What is variable? )n identi ier is used to identi y and store so%e value# 1 the value o the identi ier is changed during the e;ecution o the progra%/ then the identi ier is 3nown as variable# 19) What are the rules or the identi ier?

(he irst character %ust be an alphabet or underscore -C)

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

Digits %ay be included in the variable (he %a;i%u% nu%ber o characters in a word are ,2 -1t %ay vary depending upon the plat or%) 7o other special characters are allowed#

2?) What are global variables? @lobal Dariables are those/ which are re8uired to be acccessed by all the unctions de ined a ter their declaration# 5o/ the variables declared be ore the %ain E) can be acccessed by all the unctions/ which ollow their declaration# 21) What is a 3eyword? 'eywords are those words o C which have prede ined %eaning assigned by the C language# (hey or% a part o the database re8uired by the C co%piler# 22) What are the di erent types o c instructions?

(here are basically three types o instructions in C are > (ype Declaration 1nstruction )rith%etic 1nstruction Control 1nstruction

2,) What is an e;pression? +;pression is de ined as a co%bination o operands and operators to obtain so%e co%putation# 4perands represent variables or values and (he operator tells is what operation to be per or%ed# 20) What are the types o data iles?

(here are two types o data iles > strea% oriented or standard data iles syste% oriented or low level data iles

22) Why C is called a %iddle level language? C co%bines the eatures o both )sse%bly Level Languages -Low Level Languages) and $igher Level Languages# 6or this reason/ C is re erred to as a .iddle Level Language# (he eature o )LLs is that o enabling us to develop syste% level progra%s and the eatures o $LLs are those o higher degree o readability and %achine independence# 2:) $ow can variables be characteriFed? (he variables can be categoriFed by storage class as well as by data type# (he storage class speci ies the portion o the progra% within which the variables are recogniFed#

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

27) @ive the rules or variable declaration?


(he rules or variable declaration in C are given below > ) variable na%e consists o alphabets/ digits and the underscore -C) character (he length o variable should be 3ept upto = characters though your syste% %ay allow upto 0? characters (hey %ust begin with an alphabet 5o%e syste%s also recogniFe an underscore as the irst character White space and co%%as are not allowed )ny reserved word -3eyword) cannot be used as a variable na%e#

2=) What is the purpose o type declarations? (he type declaration allow to create a synony% or other data types# 1ts synta; is typede type identi ierG (he declaration typede unsigned long int 17(+@+R 29) What is recursion? C language a unction %ay call another unction# When a unction calls itsel / it is re erred to as recursive call and the process is 3nown as recursion# C provides very good acilities or recursion# ,?) What is data types? Data types re er to the classes o data that can be %anipulated by C progra%s# (he three unda%ental data types supported by C are character/ integer and real type# ,1) What are the types o %acro or%ats?

(here are two types o %acro or%ats# (here are 5i%ple "ara%eteriFed

,2) What are the di erent types o errors?


Co%pile9(i%e +rrors Lin3er +rrors Runti%e +rrors Logical +rrors

,,) What is %eant by errors and debugging? +rrors %ay be %ade during progra% creation even by e;perienced progra%%ers# 5uch type o errors are detected by the co%piler# Debugging %eans re%oving the errors##

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

,0) What is the purpose o %ain-) unction?


(he unction %ain-) invo3es other unctions within it#1t is the irst unction to be called when the progra% starts e;ecution# 1t is the starting unction# 1t returns an int value to the environ%ent that called the progra%# Recursive call is allowed or %ain- ) also# 1t is a userHde ined unction#

,2) What is %eant by type casting? 1t is the e;plicit type conversion re8uired or a nu%ber be ore carrying out processing or assigning to another variable# ,:) What are the pri%itive data types in c?

(here are ive di erent 3inds o data types in C# Char 1nt 6loat Double Doid

,7) What is the use o typede ? (he typede help in easier %odi ication when the progra%s are ported to another %achine#) descriptive new na%e given to the e;isting data type %ay be easier to understand the code# ,=) What is %eant by type speci iers? (ype speci iers decide the a%ount o %e%ory space occupied by a variable# 1n the ease o integral typesG it also e;plicitly states the range o values that the ob&ect can hold## ,9) What are the types o type speci iers?

(he available data type speci iers are > 5hort Long 5igned Ansigned

0?) What is %as3ing? .as3ing is a process in which a given bit pattern is partly e;tracted into another bit pattern by %eans o a logical bitwise operation#

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

01) What is the di erence between single charater constant and string constant?

) single character constant consists o only one character and it is enclosed within a pair o single 8uotes# ) string constant consists o one or %ore characters and it is enclosed within a pair o double 8uotes#

02) What is signed and unsigned? ) nu%eric value/ %ay have a positive or a negative sign# 1n the %e%ory/ or a variable/ one bit is used e;clusively to %aintain the sign o the data# 1 we donIt have sign/ the sign bit also %ay be used or data# 1 the value is negative/ the sign bit is 1/ and i it is positive/ it will be ?# 0,) What are the di erent categories o unctions in C?

1n C/ the unctions can be divided into the ollowing categories > 6unctions with no argu%ents and no return values 6unctions having argu%ents but no return values 6unctions having argu%ents and return values also

00) What is this pointer? 1t is a pointer that points to the current ob&ect# (his can be used to access the %e%bers o the current ob&ect with the help o the arrow operator 02) What is Fero based addressing? (he array subscripts always start at Fero# (he co%piler %a3es use o subscript values to identi y the ele%ents in the array# 5ince subscripts start at ?/ it is said that array uses FeroH based addressing# 0:) What is a loop? ) loop is a process to do a &ob repeatedly with possibly di erent data each ti%e# (he state%ents e;ecuted each ti%e constitute the loop body/ and each pass is called iteration# ) condition %ust be present to ter%inate the loop# 07) What are the types o data types and e;plain?

(here are ive basic Data types in C# (hese are > void > %eans nothing i#e# no data involve%ent in an action char > to wor3 with all types o characters used in co%puter operations int > to wor3 with an integer type o data in any co%putational wor3 loat > to wor3 with the real type o data or scienti ic nu%bers in the e;ponential or% double > to wor3 with double precision o nu%bers when the appro;i%ation is very crucial#

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

0=) What is riend unction? (he unction declaration should be preceded by the 3eyword riend#(he unction de initions does not use either the 3eyword or the scope operator >># (he unctions that are declared with the 3eyword riend as riend unction#(hus/ a riend unction is an ordinary unction or a %e%ber o another class# 09) What is brea3 state%ent? When a brea3 is encountered inside a loop/ the loop is ter%inated and the control passes to the state%ent ollowing the body o the loop# 2?) What is the use o getchar-) unction? 1t returns a character &ust entered ro% the standard input unit/ that is/ 3eyboard# (he entered character can be either assigned to a character variable or echoed to the co%puter screen#

21) What is a pointer? ) pointer is a variable that represents the location -rather than the value) o a data ite%/ such as a variable or an array ele%ent# 1t is a variable that holds a %e%ory address# (his address is the location o another variable or an array ele%ent in %e%ory# 22) $ow to declare pointer variables? 1 a variable is going to be a pointer/ it %ust be declared as such# ) pointer declaration consists o a base type/ an J/ and the variable na%e# (he general or% or declaring a pointer variable is data Ctype J varC na%eG 2,) What is the di erence between read bu er-) and write bu er-)? 6read-)/ bu er is a pointer to an area o %e%ory that will receive the data ro% the ile# 6or write-)/ bu er is a pointer to the in or%ation that will be written to the ile# (he value o count deter%ines how %any ite%s are read or written/ with each ite% being nu%Cbyte bytes in length# (he siFeCt in both the or%ats is de ined as so%e 3ind o unsigned integer# 6inally/ p is a ile pointer to a previously opened ile# 20) What is %acro? (he second preprocessor unction is %acro de inition# ) %acro is or%al synta; that can be used to generate state%ents or use in a progra%# 6or the C language/ the %acro generates C state%ents# 22) What are the types o 1<4 unctions?

1<4 unctions are grouped into two categories > An or%atted 1<4 unctions 6or%atted 1<4 unctions

2:) What is the di erence b<w or%atted*un or%atted 1<4 unctions?

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

(he or%atted 1<4 unctions allow progra%%ers to speci y the type o data and the way in which it should be read in or written out# 4n the other hand/ un or%atted 1<4 unctions do not speci y the type o data and the way is should be read or written# 27) $ow to declare pointer variables? 1 a variable is going to be a pointer/ it %ust be declared as such# ) pointer declaration consists o a base type/ an J/ and the variable na%e# (he general or% or declaring a pointer variable is data Ctype J varC na%eG 2=) What is the di erence between c *cKK? cKK is an ob&ect oriented progra%ing but c is a procedure oriented progra%ing#c is super set o cKK# c canIt suport inheritance/ unction overloading/ %ethod overloading etc# but cKK can do this#1n cHprogra%e the %ain unction could not return a value but in the cKK the %ain unction shuld return a value# 29) What is the use o putchar unction? (he putchar unction displays one character on the display %onitor# (he character to be displayed is o type char# (he synta; or putchar unction is as given below >putchar -chCvar)G Where chCvar is a previously declared character variable# :?) What is the use o getchar unctions? (he getchar unction accepts a single character ro% the 3eyboard# (he unction does not re8uire any argu%ents/ though a pair o e%pty parentheses %ust ollow the word getchar as a synta;# 1t returns a single character ro% a standard input device -typically a 3eyboard ) and it can be assigned to predeclared character variable# :1) What is character constants? ) character constant is a single character/ enclosed within the pair o single 8uotation %ar3 -apostrophes)# :2) What is string constants? ) string constant or literal contains a se8uence o Fero or %ore characters or escape seauences enclosed in double Buotation %ar3s# :,) What is integer constants? )n integer constant is an integerHvalued nu%ber# 1t can represent deci%al/ octal/ or he;adeci%al values# :0) What is loating point constants?

6loatingHpoint constants are nu%bers with deci%al parts# ) loatingHpoint constants consists o > )n integral part ) deci%al point ) ractional part )n e;ponent part )n optional su i;

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

:2) What is the di erence between read and write unction? (he read-) unction returns the nu%ber o ite%s read# (his value %ay be less than count i the end o the ile is reached or an error occurs# (he write-) unction returns the nu%ber o ite%s written# (his value will e8ual count unless an error occurs# ::)What are the uses o a pointer?

"ointer is used in the ollowing cases 1t is used to access array ele%ents 1t is used or dyna%ic %e%ory allocation 1t is used in Call by re erence 1t is used in data structures li3e trees/ graph/ lin3ed list etc#

:7) What are lin3er error? (he Lin3er +rrors occur during the lin3ing process when the e;ternal sy%bols re erred to by the progra% are not resolved# :=) What are runti%e error? (he Runti%e +rrors occur while a progra% is being run and hence the na%e# (hey occur due to both progra% internal and e;ternal actors# # :9) When do we get logical errors?

(he Logical +rrors occur i the solution procedure or the given proble% itsel is wrong# 1n this case/ the outputs produced by the progra%s would be incorrect# Correcting the solution procedure itsel by better understanding o the proble% eli%inates these errors# (he Logical +rrors -i any) are to be igured out by ourselves by veri ying the outputs that are produced by the progra%#

7?) Do character constants represent nu%erical values? Les/ each character constant associates an integer value with it# 71) What is the purpose o scan -) and print -) unctions?

(he unction scan -) is used or or%atted input ro% the standard input and provides %any o the conversion acilities# 1t is used or or%atted output to standard output device/ that is/ screen# (he or%at speci ication string and the data to be output/ are the argu%ents -para%eters) to the print -) unction#

72) What is type 8uali iers?

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

(ype 8uali ier adds properties to an identi ier# (ype 8uali iers describe the %anner in which the ob&ect will be %odi ied# (he application o 8uali iers to an ob&ect does not a ect the range or the arith%etic properties o the ob&ect# 7,) What are the types o type 8uali iers in c?

(he two type 8uali iers provided by C are > const volatile

70) What is %eant by inheritance? 1nheritance is the process by which ob&ects o one class ac8uire properties o ob&ects o another class## 72) Do string constants represent nu%erical values? 7o/ the string constants donot have a corresponding nu%erical value# 7:) What is %eant by operator precedence? 4perator precedence describes the order in which C evaluates di erent operators in a co%ple; e;pression# 77) What is an 4perator? )n operator is a sy%bol/ which instructs the co%puter to per or% the speci ied %anipulation over so%e data# (he rich set o operators available in C enable us to write e icient and concise progra%s and this act serves to set C apart ro% any other progra%%ing languages# 7=) What are the types o operators in c?

)ssign%ent operator )rith%etic operators Relational operators Logical operators 1ncre%ent<Decre%ent operators 5horthand arith%etic assign%ent operators Conditional operator !itwise operators 5iFeo -) operator Co%%a operator

79) What is a ternary operator in C? "erhaps the %ost unusual operator in C language is one called the conditional e;pression operator# Anli3e all other operators in C which are either unary or binary operators the conditional e;pression operator is a ternary operatorG that is/ it ta3es three operands# (he two sy%bols that are used to denote this operator are the 8uestion %ar3 -?) and the colon ->)# (he irst operand is placed be ore the ?/ the second between the ? and the and the third a ter the >#

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

=?) What is assign%ent operator? )n operator is a sy%bol that operates on a certain data type#1n C/ the MNM sy%bol is 3nown as the assign%ent operator# 1t sots the value o the variable on the le t hand side o it to that o the right hand side o it# =1) What are the types o assign%ent state%ents?

C supports a variety o assign%ent state%ents# (hese are given below > 5i%ple assign%ent state%ent .ultiple assign%ent state%ent )rith%etic assign%ent state%ent

=2) What is the siFeo -) operator? +ven though it loo3s li3e a 3eyword/ siFeo - ) is an operator which is used to 3now the %e%ory siFe o the data types and variables# (his operator returns the nu%ber o bytes allocated or the variable -or) data type# (he or%at o the siFeo -) operator is as ollows# siFeo -v)G where v is a variable na%e < data type < value# =,) What is the use o bitwise operator? (he bitwise operator per or%s the operation on bits -i#e# bit by bit)# Asing the bitwise operators we can set < reset < chec3 any bit in the value o the variable#

=0) What is the Di erence between N and N N 4perators? (he two operators N and NN are used or assign%ent and chec3ing respectively# 1 not properly used/ it causes %any proble%s# (he ollowing progra% illustrates what will happen i we use N instead o N N# =2) What is unary operator? (he operators that act upon a single operand to produce a new value are 3nown as unary operators# =:) What are the types o unary operators?

C support unary operators are > %inus operator H incre%ent operator K K decre%ent operator 9 siFe operator -type) operator

=7) What is the di erence between brea3 and continue?

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

(he brea3 state%ent is used to e;it ro% all the loop constructs -while/ do while and or) and switch#case state%ents/ whereas the continue state%ent is used to s3ip all subse8uent instructions and can control bac3 to the loop control# (he continue state%ent can be used or any loop construct# ==)What is storage class? (he storage class in C provides the co%plete in or%ation about the location and visibility o variables# 5cope o a variable %eans the portion o the progra% within which it can be re erenced and li eti%e %eans the ti%e o its e;istence in the %e%ory# =9) What are the di erent storage classes in C?

(here are our types o storage classes# )uto%atic > Dariable used as a local variable# (his is the de ault one# 1nitial value o variable is garbage value without initialiFation# +;tern > Dariable used as a local variable# Retains its value during ne;t unction call# Regiter > Dariable used as a local variable# .ay be stored in register i possible# De ault initial value is garbage value# 5tatic > Dariable used as a global variable#

9?) What are the types o bitwise operator?


(here are three types o bitwise operator# !itwise )7D-*) !itwise 4R-O) !itwise +;clusive 4R-P)

91) What is di erence between unction overloading and operator overloading? ) unction is overloaded when sa%e na%e is given to di erent unction#While overloading a unction/ the return type o the unctions need to be the sa%e# 92) What is getche-) unction? 1t returns a character &ust entered ro% the standard input unit# (he entered character is echoed -displayed) to the co%puter screen# 1t reads a single character the %o%ent it is typed without waiting or the +nter 3ey to be hit# 9,) What is getch-) unction? 1t returns a character &ust entered ro% the standard input unit# (he entered character is not echoed on the screen# 1t reads a single character the %o%ent it is typed without waiting or the +nter 3ey to be hit# 90) What is putchar-) unction? 1t prints the character constant or the character variable to the standard output device# (he unction putchar- ) has the ollowing or% > putchar -var na%e)

Freshers Jobs In India | Interview Preparation | Puzzles www.fresherventure.net

92) What is an arrays? )rrays can be de ined as a collection o variables o the sa%e type that are re erred through a co%%on na%e# 9:) What are the advantages o the unctions?

1t reduces the co%ple;ity in a progra% by reducing the code 6unction are easily understanding and reliability and e;ecution is aster 1t also reduces the ti%e to run a progra%#1n other way/ 1ts directly proportional to co%ple;ity 1tMs easy to indHout the errors due to the bloc3s %ade as unction de inition outside the %ain unction#

97) What are the characteristics o arrays in C?


)n array holds ele%ents that have the sa%e data type )rray ele%ents are stored in subse8uent %e%ory locations (wo9di%ensional array ele%ents are stored row by row in subse8uent %e%ory locations )rray na%e represents the address o the starting ele%ent )rray siFe should be %entioned in the declaration# )rray siFe %ust be a constant e;pression and not a variable#

9=) What is the di erence between arrays and pointers? )rray is collection o si%ilar datatype# it is a static %e%ory allocation %eans we can not incre%ent and decre%ent the arry siFe once we allocated# and we can not incre%ent the base address/ reassign address# "ointer is a dyna%ic %e%ory allocation# we can allocate the siFe as we want/ assigning into another variable and base address incre%entation is allowed# 99) What is else i ladder? (he else i ladder helps select one out o %any alternative bloc3s o state%ents or e;ecution depending on the %utually e;clusive conditions# 1??) What is class? ) class represents description o ob&ects that share sa%e attributes and actions# 1t de ines the characteristics o the ob&ects such as attributes and actions or behaviors# 1t is the blue print that describes ob&ects#

You might also like