Sei sulla pagina 1di 10

C INTERVIEW QUESTION

Explain the keyword continue.


It i! u!ed to take the control to the "e#innin# o$ the loop.
It "ypa!!e! the !tate%ent! in!ide the loop& which ha'e not "een executed.
Continue !tate%ent i! #enerally pre!ent within a loop and a!!ociated with i$ !tate%ent.
Exa%ple(
int i& )*
$or + i,- * -.,/ * i001
2
$or + ),- * ).,/* )001
2
i$ +i,,)1
continue *
print$ +34n5d 5d4n6&i&)1*
7
7
Output o$ pro#ra% i! -/
/-
When the continue !tate%ent take! control it "ypa!!e! the re%ainin# !tate%ent! o$ the inner $or loop.
8ow are deci!ion! %ade u!in# a !witch keyword9
Switch i! co%"ined with ca!e and de$ault keyword! to %ake a control !tate%ent.
Syntax( !witch+inte#er expre!!ion1
2
ca!e con!tant -(
do thi!*
ca!e con!tant /(
do thi!*
ca!e con!tant n(
do thi!*
de$ault(
do thi!*
7
The inte#er expre!!ion yield! an inte#er 'alue.
Thi! inte#er 'alue i! %atched with ca!e con!tant and i$ condition $or any ca!e i! true it execute! the !tate%ent!
$ollowin# the ca!e !tate%ent.
I$ no ca!e %atche! then !tate%ent! $ollowin# de$ault are executed.
What i! the : ; R %ethod to declare $or%al ar#u%ent! in a $unction .
: ; R i! called a! the :erni#han and Ritchie %ethod o$ declarin# ar#u%ent!.
Exa%ple( cal!u%+x& y& <1
int x& y& <*
here x&y&< are the $or%al para%eter!.
8ere the 'alue! x& y& < are de$ined in the $ir!t !tate%ent +$unction declaration1.
Their data type! are de$ined in the !econd !tate%ent.
=i'e one %ethod $or declaration o$ $or%al para%eter!.
>or%al para%eter! can "e declared u!in# ?NSI %ethod .
In thi! %ethod the data type! o$ the para%eter! are de$ined in the $unction declaration.
1
The data type! u!ed can "e inte#er& $loat& char& etc.
Exa%ple( cal!u%+int x& int y& int <1
8ere x&y&< are the $or%al para%eter!.
What i! #ar"a#e 'alue and how it can "e a'oided9
I$ a $unction i! not returnin# any !peci$ic 'alue &it return! data called #ar"a#e 'alue.
Exa%ple( return+a1* ?
return * @
In !tate%ent ? a !peci$ied 'alue AaB i! returned.
In !tate%ent @ no !peci$ied 'alue pre!ent !o it return! a #ar"a#e 'alue.
To a'oid the #ar"a#e 'alue keyword 'oid i! placed "e$ore the $unction na%e.
Exa%ple( 'oid di!play + 1
2
print$ +3welco%e61*
7
=i'e the di$$erence "etween call "y 'alue and call "y re$erence.
When a $unction i! called it pa!!e! 'alue! o$ 'aria"le! to called $unction!.
Thi! i! called a! call "y 'alue and we ha'e acce!! to $or%al para%eter!.
Exa%ple( !u%, cal!u%+ a& "& c1*
8ere cal!u% i! the $unction and a& "& c are the 'alue! pa!!ed.
I$ in!tead o$ the 'alue! the addre!!e! o$ 'alue are pa!!ed it i! called a! call "y re$erence.
To pa!! 'alue! u!in# call "y re$erence pointer! are u!ed and we ha'e acce!! to actual para%eter!.
Which 'aria"le! alway! contain whole nu%"er!9
Cointer! are the 'aria"le! which alway! contain data in the $or% o$ whole nu%"er!.
They !tore the addre!! o$ other 'aria"le!.
They are declared a! data type Dna%e o$ 'aria"le.
It al!o u!e! other operator A;B which return! the addre!! o$ the 'aria"le.
Exa%ple* ), ;i
8ere ) i! a 'aria"le that hold! the addre!! o$ other 'aria"le i.
Explain recur!ion.
? $unction i! called recur!i'e i$ a !tate%ent within the $unction can call the !a%e $unction.
In circular de$inition it i! the proce!! o$ de$inin# !o%ethin# in ter%! o$ it!el$.
It i! repre!ented a! rec+ 1.
?n i$ !tate%ent i! u!ed within recur!i'e !tate%ent to a'oid in$inite loop.
Exa%ple( rec + int x1
2
int $*
i$ +x,, -1
return + - 1*
el!e
$,xDrec+xE-1*
return + $ 1*
7
>unction to $ind the $actorial o$ a nu%"er.
Can u!er de$ined $unction! "e added to the li"rary 9I$ ye!& explain.
2
Fe!& the u!er de$ined $unction! can "e added to the li"rary.
?l!o di$$erent co%piler! pro'ide di$$erent utilitie! to %odi$y $unction! and $or c co%piler! utility called 3tli".exe6
+Tur"o li"rary1 i! u!ed.
Initially create the $unction and then co%pile the $ile u!in# ?lt $G.
Thi! $ile contain! the code in %achine lan#ua#e and then add $ile to the li"rary u!in# the co%%and 3 c(4.Htli"
%ath.li" 0 c(4$ilena%e.o") 3
Ieclare the prototype o$ $unction in the header $ile.
To include it in a pro#ra% u!e !yntax ( Jinclude 3c(44$ilena%e.h6.
Explain the auto%atic and !tatic !tora#e cla!!e!.
?uto%atic and !tatic !tora#e cla!!e! $or 'aria"le! de$ined u!e! %e%ory a! the !tora#e.
The!e cla!!e! are local to the "lock in which 'aria"le! are de$ined.
?uto%atic cla!! u!e! the #ar"a#e 'alue a! the de$ault initial 'alue.
Static cla!! u!e! the de$ault initial 'alue a! <ero.
The!e cla!!e! re%ain till the control re%ain! within "lock in which the 'aria"le i! de$ined.
=i'e an exa%ple o$ e!cape !eKuence in c.
Newline character i! the exa%ple o$ e!cape !eKuence in c.
It i! repre!ented "y !y%"ol 4n and i! placed at the o$ control !trin#.
It i! co%po!ed o$ / character! "ut i! tran!lated "y the co%piler into !in#le character.
It in!truct! the co%puter to %o'e to the next line "e$ore the in$or%ation i! printed.
Exa%ple( print$+3welco%e to c 34n61 *
What i! the di$$erence "etween the / #i'en !tate%ent!9
?1 print$+3The61*
print$+3rain61*
@1 print$+3The4nrain61*
? !tate%ent i! printed a!( Therain
It i! !o "ecau!e no newline character i! pre!ent "etweenB theB andB rainB.
@ !tate%ent i! printed a! ( The
rain
8ere the newline character i! pre!ent "etween the word! !o ArainB !hi$t! to the next line.
8ere the nu%"er o$ line! di!played are deter%ined "y how %any newline character! appear in the control !trin#.
What i! con'er!ion !peci$ication9
Con'er!ion !peci$ication i! a co%po!ite !y%"ol repre!ented "y A5dB.
Value o$ inte#er which appear! in the print$ !tate%ent i! con'erted into deci%al.
8ere AdB repre!ent! the deci%al 'alue and the #i'en inte#er i! tran!lated into inte#er.
Exa%ple ( 2
int hour!, /L*
print$+3There are 5d hour! in a day .4n6& hour!1*
7
It print! ( There are /L hour! in a day.
What i! coercion9
It !how! how the operand! o$ di$$erent type! are con'erted into %ixed %ode expre!!ion.
It i! acco%pli!hed u!in# ca!t operator.
The na%e o$ data type to "e con'erted i! enclo!ed in parenthe!e! and placed to the le$t o$ 'alue to "e con'erted.
3
Exa%ple( int a, M*
>loat ", +$loat1 a 0 -.N
8ere ca!t operator con'ert! 'alue o$ AaB to it! eKui'alent $loat "e$ore addition o$ -.N.
Which $unction i! u!ed to input the 'alue! durin# execution o$ a pro#ra%9
The $unction !can$ i! u!ed to input the 'alue! durin# execution o$ a pro#ra%.
Scan$ !tand! $or !can $unction or !can $or%attin#.
Syntax( !can$+35d6& ;n1*
5d !how! the data type o$ 'alue entered and the 'alue i! !tored inB nB.
It i! u!ed where a nu%eric 'alue or character i! to "e read into !i%ple 'aria"le.
i$ +c O, d1
print$ +3c i! not eKual to d.4n1*
d,c*
el!e
print$+ 3c i! eKual to d.4n1*
I! thi! !tate%ent 'alid or in'alid9
Thi! !tate%ent i! in'alid a! a !tate%ent i! pre!ent "etween i$ and el!e clau!e.
>ir!t !tate%ent i! part o$ i$ clau!e and !econd !tate%ent i! part o$ el!e clau!e.
8ere the a!!i#n%ent !tate%ent "elon#! neither to i$ nor to el!e clau!e.
The !yntax o$ i$Eel!e !tate%ent i!
i$ + expre!!ion1
!tate%ent-*
el!e +expre!!ion1
!tate%ent /*
Explain trailer techniKue.
It i! the !pecial end o$ data 'alue that trail! all the %eanin# data.
8ere a !uita"le condition i! u!ed that ter%inate the loop when condition i! $al!e.
One way i! to choo!e a nu%"er that the u!er would ne'er a!k pro#ra% to proce!!.
Exa%ple( i$ pro#ra% reKuire! that u!er type in a radiu!& then enterin# ne#ati'e nu%"er %ay "e the way to ter%inate
the proce!!.
8ere way! are pro'ided to ter%inate the loop in u!e.
Explain the ternary operator!.
The conditional operator! 9 and ( are called a! the ternary operator!.
The!e operator! take three ar#u%ent! .
They $or% the i$ then el!e !tate%ent! and u!e a particular !yntax.
Syntax( expre!!ion -9 expre!!ion /( expre!!ion P.
I$ expre!!ion - i! true then 'alue returned i! expre!!ion /.
Otherwi!e the 'alue returned i! expre!!ion P.
Coint out the error in the expre!!ion aH" 9 #,a ( #,"*
Thi! expre!!ion #i'e an error AQ 'alued reKuiredB.
The error can "e o'erco%e "y enclo!in# the !tate%ent in the ( part within parenthe!i!.
Correct expre!!ion i! aH" 9 #,a ( +#,"1*
In a"!ence o$ parenthe!i! the co%piler con!ider! that A"B i! "ein# a!!i#ned to expre!!ion to the le$t o$ ,.
Thi! i! the li%itation o$ conditional operator that only one C !tate%ent can occur a$ter 9 or( .
4
Which !tate%ent i! u!ed to )u%p out o$ loop in!tantly9
:eyword "reak i! u!ed to )u%p out o$ loop without waitin# $or conditional te!t.
?$ter "reak !tate%ent the control auto%atically pa!!e! to the $ir!t !tate%ent a$ter the loop.
It "reak! the control only $ro% the loop in which it i! placed.
Exa%ple( i$+P/ R/ ,,N1
2
print$+3nu%"er i! e'en61*
"reak*
7
Define the scope of static variables.
The !cope o$ a !tatic 'aria"le i! local to the "lock in which the 'aria"le i! de$ined..............
What are volatile variables?
Volatile 'aria"le! #et !pecial attention $ro% the co%piler. ? 'aria"le declared with the 'olatile keyword %ay "e
%odi$ied externally $ro% the declarin# $unction................
Explain the meaning of "Segmentation violation".
? !e#%entation 'iolation u!ually indicate! an atte%pt to acce!! %e%ory which doe!nSt e'en exi!t............
What is "Bus error"?
? "u! error indicate! an atte%pt to acce!! %e%ory in an ille#al way&perhap! due to an unali#ned pointer...........
Define recursion in C
? pro#ra%%in# techniKue in which a $unction %ay call it!el$. Recur!i'e pro#ra%%in# i! e!pecially wellE!uited to
par!in# ne!ted %arkup !tructure!.............
What does static variable mean in C?
!tatic i! an acce!! Kuali$ier that li%it! the !cope "ut cau!e! the 'aria"le to exi!t $or the li$eti%e o$ the
pro#ra%....................
List out differences between structures and arrays
The $ollowin# are the di$$erence! "etween !tructure! and array!( E ?rray ele%ent! are ho%o#eneou!. Structure
ele%ent! are o$ di$$erent data type.............
Define macros. What are the advantages and disadvantages of Macros?
? %acro i! a na%e #i'en to a "lock o$ C !tate%ent! a! a preEproce!!or directi'e. @ein# a preEproce!!or& the "lock o$
code i! co%%unicated to the co%piler "e$ore enterin#............
List out differences between pass by reference and pass by value
Ca!! "y 'alue alway! in'oke! R call! the $unction or return! a 'alue that i! "a!ed on the 'alue. Thi! 'alue i! pa!!ed a!
a con!tant or a 'aria"le with 'alue.............
Define static identifier in C?
The !tatic identi$ier i! u!ed $or initiali<in# only once& and the 'alue retain! durin# the li$e ti%e o$ the pro#ra% R
application. ? !eparate %e%ory i! allocated $or A!taticB 'aria"le!............
What are the auto variables? Where are they stored?
The auto 'aria"le! are !tored in the %e%ory o$ the !y!te%. The keyword AautoB i! optional. Tany o$ the 'aria"le!
u!ed "y the pro#ra%.............
List out differences between arrays and linked list
The di$$erence "etween array! and linked li!t! are( E ?rray! are linear data !tructure!. Qinked li!t! are linear and nonE
5
linear data !tructure!............
Eplain the term enumerations in C
? !et o$ na%ed inte#er con!tant! i! known a! an enu%eration. The enu%eration type declaration include! the na%e
o$ the enu%eration ta# and the de$inition o$ a !et o$ na%ed inte#er!............
Describe about storage allocation and scope of global! etern! static! local and register variables
The !tora#e allocation R cla!! deter%ine the %e%ory part where the !tora#e !pace i! allocated $or 'aria"le!& $unction!
and how lon# the allocation o$ !tora#e continue! to exi!t............
Define register variables. What are the advantages of using register variables?
The 'aria"le! o$ Are#i!terB type %odi$ier will in$or% the co%piler $or !torin# the 'aria"le! in a re#i!ter o$
CCU.............
What is the use of typedef?
The keyword typede$ i! u!ed $or de$inin# u!er de$ined data type!. ? new de$inition o$ exi!tin# data type! i! created
"y u!in# typede$...............
Can we specify variable field width in a scanf"# format string? $f possible how?
It i! po!!i"le to !peci$y 'aria"le $ield width in a !can$+1 $or%at !trin#. @y u!in# 5! control !trin#...........
%ut of fgets"# and gets"# which function is safe to use and why?
The $unction $#et!+1 $unction i! !a$er to u!e. It check! the "ound!.........
List out differences between strdup"# and strcpy"#
The $unction !trcpy+1 will not allocate the %e%ory !pace to copy..............
What is the difference between char &a and char a'(?
>or charUV array& !uch !i<e i! not accepted "y the co%piler. I$ the !i<e i! !peci$ied& the $ollowin# are the di$$erence!
"etween char Da and char aUV...........
Define void pointer
? 'oid pointer i! pointer which ha! no !peci$ied data type. The keyword A'oidB i! preceded the pointer
'aria"le.............
What is a const pointer?
? con!t pointer i! not the pointer to con!tant& it i! the con!tant. >or exa%ple& intD con!t ptr* indicate! that ptr i! a
pointer..............
Eplain memory leak
?n unwanted increa!e in pro#ra%! i! re$erred a! a %e%ory leak i! C lan#ua#e. The intake o$ pro#ra%
increa!e!...............
What is static memory allocation and dynamic memory allocation?
Static Te%ory ?llocation( Te%ory i! allocated $or the declared 'aria"le "y the co%piler............
What is the purpose of main" # function?
The $unction %ain+1 call! R in'oke! other $unction! within it. The execution o$ the pro#ra% alway! !tart! with %ain+1
$unction...........
What is the difference between )define and constant in C?
? Jde$ine i! u!ed a! i%%ediate con!tant or a! a %acro. Where a! the con!tant i! a 'aria"le who!e 'alue can not
chan#e.............
What are storage class in c?
The !cope and li$eti%e o$ a 'aria"le or R and $unction within a C pro#ra% i! de$ined "y !tora#e cla!!. There are $our
6
!tora#e cla!!e! in C............
Difference between *unction to pointer and pointer to function
? $unction to pointer i! one which return! a pointer.............
What is the difference between a string and an array?
The $ollowin# are the di$$erence!( E Strin# can hold only char data. Where a! an array can hold any data type.............
What do you think about the following?
int i;
scanf("%d", i);
printf("%d", i);
- The progra will copile without any errors!
- When you try to enter a "alue using "stdin", the syste will try to store the "alue at location with address "i"! "i"
ight be in"alid leading the progra to crash and core dup!
- #t iplies that this code has a bug!
What will be the output of the following?
int ain()
ain();
return $;
- %unt tie error! &tack o"erflow!
What are the ad"antages os using linked list for tree construction?
- 'nless the eory is full, o"erflow will ne"er occur!
- #nsertions ( deletions are easier in coparison to arrays!
- )o"ing pointer is faster ( easier in coparison to o"ing ites when records are large!
Which data structure is used to perfor recursion?
- &tack data structure is used to perfor recursion!
- #ts *#+, property stores return addresses of the -caller- and its successions in recursion to find where the e.ecution
control should return!
/.plain the following!
a!) 0ueue -
- 0ueue is a +#+, or *#+, data structure!
- #t perits two operations - en1ueue ( de1ueue!
- The ethods used to check the status of the 1ueue are - epty() and full()
b!) 2riority 0ueues -
- *ist of ites with priority associated with it!
- 2riority 1ueues effecti"ely support finding the ite with highest priority across a series of operations!
- 3asic priority 1ueue operations are - insert, find a.iu or iniu, delete a.iu or iniu!
/.plain the following!
a! ) 3inary height balanced tree-
- #t is a binary tree in which for e"ery node the heights of left and right subtree differ by not ore than 4!
b!) Ternary tree -
- #n this tree a node can ha"e 5ero or ore child nodes!
c!) %ed-black trees -
#t is a binary search tree with following propoerties6
- %oot is black!
- /"ery leaf is black!
- /"ery node is either red or black!
7
- +or a red red node, both its children are black!
- 7ll internal nodes ha"e two children !
- /"ery siple path fro node to a descendant leaf contains the sae no! of black nodes!
What is "3us error"?
7 8bus error9 is certain undefined beha"ior result type! The cause for such error on a syste could not be specified by
the : language! The eory accessibility which :2' could not address physically, 8bus error9 occurs! 7lso, any fault
detected by a de"ice by the coputer syste can also be a 8bus error9! These errors caused by progras that
generate undefined beha"ior which : language no longer specifies what can happen!
;ifferentiate between6 a!) ;eclaring a "ariable b!) ;efining a "ariable
a!) ;eclaring a "ariable - ;eclaration infors the copiler about si5e and type of "ariable at the tie of copilation!
<o space is reser"ed in the eory as a result of declaring the "ariables!
b!) ;efining a "ariable - eans declaring it and reser"ing a place for it in the eory!
;efining a "ariable = ;eclaration > &pace reser"ation!
Where are auto "ariables stored? What are the characteristics of an auto "ariable?
7uto "ariables are defined under autoatic storage class! They are stored in ain eory!
- )ain eory
- :2' registers
)eory is allocated to an autoatic "ariable when the block containing it is called! When the block e.ecution is
copleted, it is de-allocated!
:haracteristic of auto "ariables6
- &tored in6 ain eory
- ;efault "alue6 garbage
- &cope6 *ocal to the block where it is defined
- *ife6 Till the control stays in the block where it is defined
Why do we use naespace feature?
- )ultiple library pro"iders ight use coon global identifiers! This can cause nae collision when an application
tries to link with two or ore such libraries!
- The naespace feature surrounds a library-s e.ternal declarations with a uni1ue naespace that eliinates the
potential for those collisions!
naespace ?identifier@ A naespace-body B
- 7 naespace declaration identifies and assigns a nae to a declarati"e region!
- The identifier in a naespace declaration ust be uni1ue in the declarati"e region in which it is used!
- The identifier is the nae of the naespace and is used to reference its ebers!
Cow are structure passing and returning ipleented?
- When structures are passed as arguents to functions - the whole structure is usually pushed on the stack, through
as se"eral words as are needed!
- #n order to a"oid this o"erhead, usually pointers to structures are used!
- &oe copilers siply pass a pointer to the structure, e"en though they ha"e to produce a local copy to sa"e pass-
by-"alue seantics!
- &tructures are usually returned fro functions in a position pointed to by an additional, copiler-supplied hidden
arguent to the function!
- &oe old copilers used to use uni1ue, static locations for structure returns!
What are the different properties of "ariable nuber of arguents?
The properties of "ariable nuber of arguents are as follows6
The first paraeter of the arguent should be of any data type! The in"alid
;eclaration of a function will be done like
int(a);
The "alid declaration of the function will be like6
int(char c);
"oid(int,float);
There should not be any passing fro one data type to another data type! There is also in"alid declaration on the
basis of6
8
int(int a,int b);
There should not be any blank spaces in between the two periods! The placing of any other data type can be done in
place of ellipsis!
Cow does norali5ation of huge pointer works?
Cuge pointer is the pointer that can point to the whole eory of the %7) and that can access all the segents that
are present in a progra! The norali5ation can be done depending on the icroprocessor of the syste! The
physical eory of the syste is represented in D$ bit and then there is a con"ersion of E byte or FD bit address! The
increent of the huge pointer will also affect the offset and segent address! Through the huge pointer the access
and odification of de"ice dri"er eory, "ideo eory, etc! Cuge pointer anages the o"erall syste of the
eory odel and also norali5es the o"erall use of the pointers!
What are the different types of pointers used in : language?
There are three types of pointers used in : language! These pointers are based on the old syste architecture! The
types are as follows6
a) <ear pointer6 this is the pointer that points only to the data segent! There is a restriction of using it beyond the
data segent! The near pointer can be ade by using the keyword as GnearH!
b) +ar pointer6 it will access the total eory of the syste and can be use to point to e"ery obIect used in the
eory!
c) Wild pointer6 it is a pointer that is not being initiali5ed!
What is the difference between null pointer and wild pointer?
Wild pointer is used to point to the obIect but it is not in initiali5ation phase! <ull pointer points to the base address of
a particular segent! Wild pointer consists of the addresses that are out of scope whereas null pointer consists of the
addresses that are accessible and in the scope! Wild pointer is declared and used in local scope of the segent
whereas null is used in the full scope!
What is the function of dangling pointer?
;angling pointer is used as a wild pointer only that is pointing to the eory address of the "ariable that is been
deleted fro eory location! ;angling pointer points to a eory location still e"en the pointer is being reo"ed
fro the segent! When an obIect is deleted or deallocated then the proble of dangling pointer arises! #n this
condition if the user tries to reallocate the freed eory to another process then the original progra gi"es different
beha"ior fro the one it is e.pected fro the progra!
Cow can we readJwrite &tructures froJto data files?
- #n order to copose a structure fwrite() can be used as +write((e, si5eof(e),4,fp)! e refers to a structure "ariable!
- 7 conse1uent fread() in"ocation will help in reading the structure back fro file!
- :alling function fwrite() will write out si5eof(e) byte fro the address ( e!
- ;ata files that are written as eory iages with function fwrite() will not be portable, especially if they include
floating point fields or pointers!
- This happens because structures9 eory layout is copiler and achine dependent!
;ifferentiate between ordinary "ariable and pointer in :!
,rdinary "ariable - #t is like a container which can hold any "alue! #ts "alue can be changed anytie during the
progra!
2ointer - &tores the address of the "ariable!
/.plain "far" and "near" pointers in :!
- "+ar" and "<ear" - non-standard 1ualifiers a"ilable in .KL systes only!
- <ear pointer - %efers to an address in known segent only!
- +ar pointer - :opound "alue containing a segent nuber and offset into that segent
When should you use a type cast?
Type cast should be used in two cases6
a!) To change the type of an operand to an arithetic operation so that the operation can be perfored properly!
b!) To cast pointer types to and fro "oid M, to interface with functions that return "oid pointers!
9
What are storage classes in :?
a!) 7utoatic storage classes 6 Nariable with block scope but without static specifier!
b!) &tatic storage classes6 Nariables with block scope and with static specifier! Olobal "ariables with or
without static specifier!
c!) 7llocated storage classes6 )eory obtained fro calls to alloc(), alloc() or realloc()!
What is the purpose of ain() function?
- /.ecution starts fro ain() in :
- #t can contain any nuber of stateents
- &tateents are e.ecuted in the se1uence in which they are written
- #t can call other functions! The control is passed to that function!
/!g! int ain();
,%
int ain(int argc, char Marg"?@);
/.plain arguent and its types!
7rguent 6 7n e.pression which is passed to a function by its caller for the function to perfor its task!
7rguents are of two types6 actual and foral!
- 7ctual arguent6 These are the arguents passed in a function call! They are defined in the calling function!
- +oral arguent6 +oral arguents are the paraeters in a function declaration! Their scope is local to the
function definition! They belong to the function being called and are a copy of actual arguents! :hange in foral
arguent doesn-t get reflected in actual arguent!
Which of these functions is safer to use 6 fgets(), gets()? Why?
- ,ut of the two fgets() is safer!
- gets() recei"es the string fro the keyboard and stops when the "enter" key is hit
- There is no liit to the si5e of the string which can cause eory o"er flow!
What are pointers? Why are they used?
2ointers are "ariables which store the address of other "ariables!
7da"antages of using pointers6
- They allow to pass "alues to functions using call by reference - especially useful while large si5ed arrays are passed
as argueents to functions!
- They allow dynaic allocation of eory!
- They help in resi5ing the data structures!
10