QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
-
Upload
priya-raji -
Category
Documents
-
view
222 -
download
0
Transcript of QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
1/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
GE6151 COMPUTER PROGRAMMING
QUESTION BANK
UNIT I
Short QuestionsGeneration an C!assi"i#ation o" Co$%uters& Basi# Or'ani(ation o" a
Co$%uter
1) List the four parts of a complete computer system.
(i) Hardware (ii) software (iii) data (iv) users
2) What are the advantages and disadvantages of I generation computers?
dvantages! "hese were the fastest at their time. "hey were a#le toe$ecute comple$ calculations in an efficient manner.%isadvantages! operations depended on machine language. "herefore&they are not very easy to program. "hey were not fle$i#le for manydifferent application. "hey were #ul'y and produced lot of heat.
) ive the advantages and disadvantages of II generation computers.dvantage! they were the fastest at that time. *sed assem#ly languageso
programming was easier. "hey could #e transported from one place to
other. %isadvantages! "hey were re+uired to #e placed in air,conditioned rooms. "he cost of these computers were so high that homeusers cannot afford to #uy. "hey were only special purpose computersand so& they can not #e used for general purpose applications.
-) ive the advantages and disadvantages of III generation computers.dvantages! fastest at their time. omputational time was greatlyreduced
and thus very productive. "here were easily transporta#le. "hey could#e installed easily and occupied less space. "hey were used #oth
#usiness and scientific application and thus there were consideredgeneral purpose computers.
%isadvantages! storage capacity was not high. /verall cost was high."hey were still to #e placed in air,conditioned rooms.
0) ive the advantages and disadvantages of I generation computers.dvantages! "he use of LI technology made these computers powerfulin
speed and accuracy. torage capacity was very high. "hey were highlyrelia#le and re+uired less maintenance. "hey were highly user friendly.3rograms used were highly porta#le to different computers and they are
1
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
2/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
very versatile. "hey re+uire less power to operate.
%isadvantage! very complicated mechanism is needed to assem#le thesecomputers. Wor'ing on these computers depends on the instructionsgiven #y the programmer.
4) 5ention the advantages and of generation computers over I.dvantages! %evelopment of 3ersonal %igital ssistant(3%s).3arallel processors. Invention of /ptical dis' technology.%evelopment of internet. "he users of these computers find it verycomforta#le to use #ecause of several additional multimedia features.
6) 5ention the advantages and of I generation computers over dvantages! %evelopment of 3ersonal %igital ssistant(3%s).3arallel processors. Invention of /ptical dis' technology.
%evelopment of internet. "he users of these computers find it verycomforta#le to use #ecause of several additional multimedia features.
7) %ifferentiate #etween analog and digital computers.
Ana!o' )i'ita!
"he data is represented in the form%ata is stored in terms of 8s and 1s.
of electrical pulses.
"he electronic circuit employed in "his consists of L*& control unit& a
the analog computer is an memory unit and I9/ units.
operational amplifier.
:) 5ention the various types of computers according to theirsi;e and capa#ility.
< 5icrocomputers
< 5inicomputers
< 5ainframe computers
< uper computers
18) 5ention the different categories of computers made for individual users.
a) %es'top computers#) Wor'stations
c) =ote#oo' computers
d) "a#let computers
e) Handheld computers
f) mart phones
11) List out the difference #etween mainframe computers and super
2
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
3/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
computer. Main"ra$e Co$%uter! *sed #y large #usiness organisationemploying very
huge applications such as financial transaction processing& consumer
statistics& enterprise resource planning. "he term refers to huge ca#inet with
a
central processor and a huge main memory.
Su%er Co$%uters! It is the fastest type of computers that can performcomple$ operations at a very high speed. "hey are used for (i) weatherforecasting (ii) raphics animations (iii) =uclear energy esta#lishments(iv) petroleum e$ploration. uper computers employ the fastestprocessors and they are large in num#er very large memory and storage is#eing used. 5any optimising techni+ues to enhance the performance of
the processor #y pipeling and parallelism methods.12) %raw the #loc' diagram of a computer.
1) %istinguish #etween >5 and >/5.
RAM! s new data is entered into the computer& it is also stored inmemory, #ut only temporarily. %ata is #oth written to and read fromthis memory. >5 is volatile& meaning that it loses its contents when
the computer is shut off or if there is a power failure.
3
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
4/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
ROM! It permanently stores its data& even when the computer is shutoff. >/5 is called non,volatile memory #ecause it never loses itscontents.>/5 holds instructions that the computer needs to operate.
Nu$*er S+ste$s & Binar+ )e#i$a! Con,ersion
1-) What is the weight of the digit 4 in each of the following decimal
num#ers?
(a) 174 (#) 0-&4:2 (c) 461&:28
ns! (a) 4 (#) 488 (c)
10) $press each of the following decimal num#ers as a power of ten!
(a) 18 (#) 188 (c) 18&888 (d) 1&888&888
ns! (c) 1@18- A 8@18 A 8@182 A 8@181 A 8@188
14) ive the value of each digit in the following decimal num#ers!(a) -61 (#) :04 (c) 120&888
ns! (#) : B :888 & B 88 & 0 B 08& 4 , 4
16) How high can you count with four decimaldigits? ::::
17) onvert the following #inary num#ers to decimal!
(a) 1118 (#) 1818 (c) 11188 (d) 18888 (e) 18181
ns (e) 21
1:) onvert the following #inary num#ers to decimal!(a) 118811.11 (#) 181818.81 (c) 1888881.111
ns! (c) Cor decimal 1@ 24 A 8 @ 20 A ...A 1 D 40 for fractional!
1 @ 2,1 A 1 @ 2,2 A 1 @ 2,. "hus 40.760
28) What is the highest decimal num#er that can #e represented #yeach of the following num#ers of #inary digits (#its)?
(a) two (#) three (c) four (d) five (e) si$ans! (#) 6(2
B 1)
21) How many #its are re+uired to represent the following decimal num#ers?
(a) 16 (#) 0 (c) -: (d) 47 (e) 71 ns! (c) -: D 118881 so minimum 4 #itsare needed.
22) enerate the #inary se+uence for each decimal se+uence!
(a) 8 through 6 (#) 7 through 10 (c) 14 through 1 ns!(#) 1888&1881&1818&1811&1188&1181&1118&1111
%ecimal,to,Einary onversion
2) onvert each decimal num#er to #inary(#y using the sum,of,weights method)!
(a) 18 (#) 16 (c) 2- (d) -7 (e) 41 ns! (c) 2- D 14 A 7 D 1@2-A 1@2A 8@22A8@2
1A 8@2
8so 2- D 118882
4
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
5/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
2-) onvert each decimal fraction to #inary using repeatedmultiplication #y 2 method
(a) 8.:7 (#) 8.-6 (c) 8.:827
ns! (#) [email protected]:-F 8.4:[email protected] [email protected]@2D1.002F [email protected] and so on.o& appro$imately& 8.-6 D .81811
20) onvert each decimal fraction into #inary #y using the sum,of,weights method!
(a) 8.2 (#) 8.2-4 (c) 8.8:71Einary rithmetic
24) dd the #inary num#ers!
(a) 11 A 81 (#) 18 A 18 (c) 181 A 11 (d) 111 A 118 (e) 1881 A 181 (f) 1181A 1811
26) 3erform the following #inary multiplications!
(a)11 11 (#) 188 18 (c) 111 1811Gs and 2Gs omplements of Einary=um#ers
27) %etermine the lGs complement of each #inary num#er!
(a)181 (#) 118 (c) 1818
ns! (a) 818 (#) 881 (c) 8181
2:) %etermine the 2Gs complement of each #inary num#er usingeither method!
(a) 18 (#) 111 (c) 1881 (d) 1181ns! (a) 18 (#) 881 (c) 8111 (d) 8811
igned =um#ers
8) $press each decimal num#er in #inary as an 7,#it sign,magnitude num#er!
(a) A2: (#) ,70 (c) A 188 (d) ,12ns! (a) 88811181 (#) 18181811 (c) 81188188 (d) 18888181
1) $press each decimal num#er as an 7,#it num#er in the lGscomplement form!
(a),- (#) A06 (c) ,:: (d) A110 ns! (a) 11811181(#) 88111881 (c) 18811188
2) %etermine the decimal value of each signed #inary num#er inthe 2Gs complement form!
(a) 18811881 (#) 81118188 (c) 18111111ns! (a) ,18 (#) A114 (c) ,40 rithmetic
5
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
6/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
/perations with igned =um#ers) onvert each pair of decimal num#ers to #inary and add using the 2Gs
complement form!
(a) and 10 (#) 04 and ,26and 20 (c) ,118 and ,7-
ns! 2s complement of D 88188881A2s complement of 10 D 88881111
88118888
-72s complement of 04 D 88111888
2s complement of ,26 D
11188181
88811181(no end carry)
2:
2s complement of 20 D 88811881>esult D 88118118
0-He$adecimal =um#ers-) onvert each he$adecimal num#er to #inary!
(a) 714 (#) 0:14 (c) 1-14 (d) 0714
ns! (a) 11 1888 8881 8118 (d) 8181 1188 1888 8881 8118
0) onvert each #inary num#er tohe$adecimal! (a)1118 (#) 18
ans! (a) (#) 2
4) onvert each octal num#er to decimal!
(a) 127(#) 267(c) 047(d) 4-7(e) 187ns! (a) 18 (c) -4 (d) 02 (e) 46
6) onvert each octal num#er to #inary!
(a) 17 (#) 067 (c) 1817 (d) 217 (e) 0-87ns! (a) 881 811 (#) 181 111 (c) 881888881 (e) 181 188 888
7) onvert each #inary num#er to octal!
(a) 111 (#) 18 (c) 118111 (d) 181818ns! (a) 6 (#) 2 (c) 46 (d) 02
:) onvert each of the following decimal num#ers to 7-21 E%!
(a) 18 (#) 1 (c) 104 (d) 21 (e) 20
ns! (a) 8881 8888 (c) 8881 8181 8118 (e) 8818 8181
-8) onvert each of the E% num#ers to decimal!
(a) 18888888 (#) 881888118111
ns! (a) 78 (#) 26
6
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
7/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
-1) onvert each pair of decimal num#ers to E%& and add as indicated!
(a) 27 A 2 (#) 40 A 07 (c) 11 A 181 (d) 2:0 A106 ns! (a) 27 in E% D 8818 1888
2 in E% D 8818 88118188 1811
: o add 4
arry
8881 8118
8181 8881
01 is the result.
-2) onvert each #inary num#er to raycode! (a)18811 (#) 11811
ns! (a) 11818 (#) 18118
-) onvert the ray code to #inary(a) 1811 (#) 11818ns! (a) 1181 (#)18811
Pro*!e$s- Nee "or !o'i#a! ana!+sis an thin.in'
--) What are the three steps in solving a pro#lem?
(i) *nderstand the pro#lem (ii) Cind the connection #etween thedata and the un'nown B devise a plan(iii) carry out the planand e$amine the solution o#tained.(iv) loo' #ac' B chec' if
there are more approaches.-0) tate the purpose of pro#lem solving through computers.
omputers are very fast in solving pro#lems. "he omputer calculates
with great accuracy. omputer produces results without any error.
repetitive calculation is performed with the same accuracy for any
num#er of times in a omputer. "hat is why omputers are used in
solving pro#lems.
-4) ive a formal definition for a program.n assault on large pro#lems employs a succession of programs. "hese
programs are rife with issues that appear to #e particular to the pro#lem at
hand.
-6) =ame the four paradigms of programming.
(i) *nstructured programming (ii).tructured programming and
(iii)/#Ject /riented programming (iv) spect /riented programming
-7) 5ention the types of programming languages.
(i) 5achine language
7
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
8/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
(ii) ssem#ly language
(iii)High,level language
-:) tate the re+uirements for solving pro#lem #y computers.
"o appreciate programming an as an intellectual activity in its ownright& we must turn to omputer programming. We must read andwrite computer programs B many of them.
08) =ame the different aspects of pro#lem solving.
It is widely recognised that pro#lem,solving is a creative processwhich largely defies systemati;ation and mechani;ation. "his maynot sound very encouraging to the would,#e pro#lem,solver. "o#alance this& most people& during their schooling& ac+uire at least a
modest set of pro#lem,solving s'ills which they may or may not #eaware of. Within this conte$t& then& where can we #egin to sayanything useful a#out computer pro#lem,solving? We must start fromthe premise that computer pro#lem,solving is a#out understanding.
01) What are the primary strategies of pro#lem solving?
(i) *nderstanding of the pro#lem. (ii) %eveloping a design strategy.
(iii) 3lanning the development process.
02) Illustrate the idea #ehind the top,down,design approach.
"op,down design is a strategy that we can apply to ta'e the solutionof a computer pro#lem from a vague outline to a precisely definedalgorithm and program implementation. "op,down design providesus with a way of handling the inherent logical comple$ity and detailfre+uently encountered in computer algorithms. It allows us to #uildour solutions to a pro#lem in a stepwise fashion.
0) 5ention the steps in #ottom up design with an illustration.
In a #ottom,up approach& the individual #ase elements of the system
are first specified in great detail. "hese elements are then lin'edtogether to form larger su#systems& which then in turn are lin'ed&sometimes in many levels& until a complete top,level system isformed. "his strategy often resem#les a KseedK model& where#y the#eginnings are small& #ut eventually grow in comple$ity andcompleteness. /#Ject,oriented programming (//3) is a paradigmthat uses Ko#JectsK to design applications and computer programs.
A!'orith$/ 0!o#harts an %seuo#oe
0-) %efine the term algorithm. List the characteristics of a good algorithm.n algorithmis defined as a finite se+uence of e$plicit instructions
8
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
9/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
that& when provided with a set of input values& produces an output andthen terminates. n algorithm must have no am#iguity. "hereshould not #e any uncertainty a#out the ne$t instruction e$ecution.It should terminate in a finite num#er of steps.
00) What is meant #y computational comple$ity of an algorithm?
It is the e$ecution time of the algorithm in terms of its input parameters.
04) $plain the advantages of an algorithm.
good algorithm helps the programmer to design the program in aneasier manner.
06) %efine the term pseudo,code.
3seudocode is not the actual name #ut it models and may even loo' li'eprogramming code. It is the generic way of descri#ing an algorithm
without using any programming language related notations. /r& moresimply it is the outline of the program& written in a form that can #eeasily converted into real programming statements.
07) ive the advantages and limitations of flowchart.
dvantages! it ma'es the logic clear and visual. It communicates theinterconnection of the logical system. "he pro#lem can #e well analysed.*seful for coding the pro#lem. "esting and de#ugging is easily done.Clowcharts are good programming documentation for future reference.%isadvantages! it is complicated. It is costly and difficult to modify in
future and no updates are easy to do.0:) ive the advantages and limitations of pseudocode.
dvantages! it is language independent. It is easier to developprogram from pseudocode than from flowchart. It is very compactthan a flowchart.
48) What are the three #asic program controlstructures? e+uence& selection and repetition.
UNIT I BIG QUESTIONS
1) $plain the evolution of omputers 7
2) $plain the different computer generations. 7
) $plain the classification of computer in detail. 7
-) With a #loc' diagram e$plain computer organi;ation. 7
9
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
10/41
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
11/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
2-) Write a pseudocode to multiply two matrices. 4
20) Write an algorithm to compute the factorial of a num#er 7
24) %efine a flow,chart. List the advantages of using a flowchart. 0
26) %raw a flow,chart to find the highest of mar's in a set of n 7mar's.
27) What are the advantages of using a pseudo,code? 0
2:) Write a pseudo,code to add two matrices. 7
8) %iscuss the three #asic program control structures with 4
suita#le e$amples.
1) $plain the features of a good programming language. 7
2) %escri#e the characteristics of programming languages. 7) $plain the top,down and the #ottom,up approaches in 7
program development.
-) What are the advantages of structured programming? 4
0) What is the difference #etween #lac',#o$ and white,#o$ 7testing?
UNIT II
Introu#tion to C %ro'ra$$in' "una$enta!s stru#ture o" a 2C3%ro'ra$
1) Why is language called middle,level language?
com#ines the features of high,level language and functionality li'eassem#ly language. It reduces the gap #etween high,level language andlow,level language& that is why it is 'nown as middle level language.
2) What are the functions of an interpreter and a compiler?
n interpreter reads only one line of the source program at a time andconverts into o#Ject codes. In case of errors& the same may #e indicated
instantly. "he compiler reads the entire program and converts it to the o#Ject
code. It provides errors not of one line #ut errors of entire program.
) Write the rules for writing a program.
a) ll statements should #e written in lower case. *pper case lettersare used only for sym#olic constants.
#) Elan' spaces may #e inserted #etween words. "his improvesthe reada#ility of the statements. Eut it is not used while
11
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
12/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
declaring a varia#le& 'eyword and constant and functions.
c) It is not necessary to fi$ the position of statements in the program&that is the programmer can write the statement anywhere #etweenthe two #races following the declaration part. "he user can alsowrite one or more statements in one line #y separating a semicolon
(F) #etween them.d) "he opening and closing #races should #e #alanced.
-) la#orate different sections of program.
a. Include or header file section
#. lo#al declaration.
c. Cunction main.
d. %eclaration section.
e. $ecuta#le part.
f. *ser,defined function.g. omments
0) What is the role of ( NO) curly #races in program?
"he program e$ecution starts from the opening #race (N) and ends with
the closing #race (O). Eetween these two #races the program shoulddeclare the declaration and e$ecuta#le part
4) What is meant #y compilation? $plain in detail.
"he source program statements should #e translated to o#Ject programswhich is suita#le for e$ecution #y the computer. "he translation is doneafter correcting every statement. If there is no error& the compilationproceeds and translated program are stored in another file with same filename with e$tension P.o#JQ. if any errors are there& the programmer shouldcorrect them. Lin'ing is also an essential process. It puts all other programfile and functions together that are re+uired #y the program.
6) Eriefly e$plain the functions of a lin'er.
fter the program has #een translated into o#Ject code& it is ready to #elin'ed. "his process is once again performed automatically whenever thecc orgcc command is issued under *ni$. "he purpose of the lin'ingphase is to get the program into a final form for e$ecution on the computer.If the program uses other programs that were previously processed #y thecompiler& then during this phase the programs are lin'ed together. 3rogramsthat are used from the systems program li#rary are also searched and lin'edtogether with the o#Ject program during this phase. "hese are the functionsof the lin'er.
7) What are the different standard data types?
12
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
13/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
"here are only four standard data type availa#le in .char specifies a character varia#le
int specifies an integer varia#le
float specifies a floating,point varia#le
void associates function returning no value:) What are the differences #etween signed and unsigned data types?
Si'ne inte'er Unsi'ne inte'er
igned integer occupies 2 #ytes /ccupies 2 #ytes in memory
in memory
>ange ! ,2&647 to 2&646 >ange ! 8 to 4000
Cormat specifier is Rd or Ri Cormat specifier is Ru
Ey default signed int is short Ey default unsigned int is
signed int short unsigned int
Constants/ Ienti"iers/ ,aria*!es an ata t+%es
18) What is meant #y a varia#le and a constant?
In a declaration& which consists of type& varia#le(one or more varia#les aredeclared after the type& separated #y commas) and delimited with asemicolon. 5oreover& during the type declaration& the varia#les so declared&may #e assigned with some corresponding values which has the followingformat!
type variable = expression;
"here are four #asic types of constants in . "hey are integer constants&floating,point,constants& character,constants& and string,constants.
11) What are the 'eywords? la#orate them.
"he following words are called reserved words or 'eywords and may not#e used #y the user.auto dou#le int struct
#rea' else long switch
case enum register typedef
char e$tern return union
const float short unsigned
continue for signed void
default goto si;eof volatile
do if static while
13
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
14/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
12) List the rules for declaring avaria#le. S%ata,type Svaria#le,name
1) What are identifiers?
n identifieris a se+uence of letters or digits that is& a..; or ..T or 1..:."he underscore is an identifier. Identifiers have 1 characters which aresignificant and some time more characters are considered to #esignificant. Internal identifiers are preprocessor macro names. n e$ternalidentifier starting with an underscore is reserved for the li#rary.
1. Cirst character must #e alpha#etic character or underscore.
2. 5ust consist only of alpha#etic characters& digits& or underscores.
. Cirst 1 characters of an identifier are significant.
-. It can not duplicate a reserved word(as descri#ed #efore)
1-) $plain the methods for initiali;ation of varia#les.variable-name = constant;
/r
Sdata,type Svaria#le,name UD SconstantVF
10) Write a#out space re+uirement for varia#les of different data types.
%ata type i;e(#yte)
char 1
unsigned char 1
int 2
unsigned int 2
long -
float -
dou#le 7
14) What are delimiters? $plain their uses.Language pattern of uses special 'ind of sym#ols that are terminals innature& which are called delimiters.
%elimiters *se
! colon *seful for la#el
F semicolon "erminates statement
( ) parenthesis *sed in e$pression and functions
UV s+uare*sed in array declarations
#rac'ets
14
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
15/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
NO curly #races cope of statement
hash 3re,processor directive
& omma aria#le separator
16) List any three 'eywords with their use.
/perators and e$pression& imple input and output functions
17) What is the difference #etween Rf and Rg format specifiers? an #oth#e used representing float num#ers?
%f is decimal point format where as%g is a scientific format using e$pfields.
1:) What do you mean #y type conversion? Why is it necessary?Implicit type conversion and 3romotional hierarchy!
char short int unsigned int long int u
l int float double long doubleo& when char and float are added& result will #e a float. imilarly& if along is added with a dou#le& the result will #e a dou#le according to thepromotional hierarchy& availa#le.$plicit type conversions
Cast. Ey having a unary operator called cast& we can convert the integerto a float.
28) $plain different types of operators availa#le in .
"ypes of operator ym#olic representation
rithmetic operator A& , & X& 9& and R
>elational operator &S&DD&D&SD& and YD
Logical operator MM& ZZ& and Y
Increment and decrement AA and ,,
operators
ssignment operator D
Eitwise operator M& Z& [& &SS& and \omma operator &
onditional oerator ?
21) What are the uses of comma (& ) and conditional (?) operators?
"he (&) comma operator is used to separate two or more e$pressions. "hecomma operator has the lowest priority among all other operator is .onditional operator (?) "he conditional operator contains a conditionfollowed #y two statement values. If the condition is true the firststatement is e$ecuted& otherwise the second statement. "he synta$ is as
15
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
16/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
follows!ondition ? (e$pression1)!e$pression2)F
22) What are *nary operators and their uses?
+,-,++,--,!,~,,,si"eof and#type$ are 'nown to #eunary operators.
includes a class for operators that act upon a single operand to produce a
new value. uch operators are called unary operators.*nary operators often
precede their single operands. "he most common operation is unary minus&
where the numerical constant& varia#le or e$pression is preceded #y a minus
sign. =ote that the unary operator minus is distinctly different from the
arithmetic operator which denotes su#traction(,). "he su#traction operator
o#viously re+uires two separate operands.
2) %escri#e logical operators with their return values.
/perator 5eaning
MM =%
Z Z />
"hese are referred as logical =% and logical />& respectively.
uppose that iis an integer varia#le with value and cis a charactervaria#le with value GwG and f is a floating point varia#le with value .04.everal comple$ logical e$pressions that ma'e use of these varia#les isshown #elow.
$pression Interpretation >eturn
alue
(i SD 2) MM (c -) Calse 8
(c D 04) Z Z (i DD -) "rue 1
(c YD G$G) MM (f DD .04) true 1
"he first e$pression is false #ecause& the first operand is false. Where as inthe second e$pression& the second operand is false #ut the first operandma'es it effectively true. In the third e$pression& #oth the operands aretrue.
2-) %istinguish #etween logical and #itwise operators.
Logical operators return either true or false where as #itwise operator returnsthe result of the operation.
20) What are relational operators?
"here are four relational operatorsin . "hey are
16
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
17/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
O%erator Meanin'
D greater than or e+ual to
greater than
SD less than or e+ual to
S less than
losely associated with the relational operators& there are two equalityoperators.
O%erator Meanin'
D e+ual toYD not e+ual to
24) What is the difference #etween GDG and GDDG?
D is an assignment operator and the other one is an e+uality operator.
26) What are the sym#ols used for a) /> #) =% c) ]/> d) =/"operations. /> , Z Z& =% , MM& ]/> , [& =/" , Y
27) $plain the precedence and associativity of operators inarithmetic operations.
Pre#een#e is used to determine the order in which different operators in acomple$ e$pression are evaluated.
Asso#iati,it+ is used to determine the order in which operators with the sameprecedence are evaluated in a comple$ e$pression.
2:) List the operators from higher priority to leastpriority. Highest to the lowest
1 3rimary ( )
2 3ostfi$ ( )& U V&,& AA& ,,
*nary AA&,,& si;eof& A& ,& M& X& \&( )- Einary X&R&9&A&,&SS&& SD&D& DD&YD& M&[&Z&MM&ZZ
0 "ernary ?!
4 ssignment D& AD& ,A& XD& 9D& RD& D&SSD&MD&[D&ZD
6 omma &
8) What is the difference #etween division and modular division
operations? 5odular division(R) returns the remainder after division
whereas division(9) returns the +uotient after division in the case of integer
otherwise actual +uotient in decimal points is returned
17
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
18/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
Mana'in' In%ut an Out%ut o%erators
1) What are the II codes? List the codes for digits 1 to :& to T and a to ;.1,-:(decimal) ...:,06(decimal II)& ,40(decimal II)...T,:8& a,:6(decimal) and ; B 122(decimal II).
2) What are the formatted and unformatted I9/ functions?
printf&,scanf& 'nown as formatted I9/ functions andgetchar&,putchar&,gets&,puts& functions are 'nown to #eunformatted I9/ functions.
) What is the difference #etween character I9/ and string I9/?
haracter I9/! onsider the function getchar&'"his function reads thecharacter type data from the standard input. It reads one character at a time
and till the user presses the enter 'ey. imilarly in putchar&function& itprints one character on the screen at a time& which is read #y the standardinput.
(tring )* onsider the function gets &' "hisfunction is used for accepting any string through stdin('ey#oard) untilenter 'ey is pressed. "he header file stdio'his needed forimplementing the a#ove function. imilarly puts() prints the string orthe character array.
-) What are the escape se+uences?
n escape se+uence li'e ^n provides a general and e$tensi#le mechanism forrepresenting hard,to,type or invisi#le characters. "heyre summarised in theta#le #elow
scape se+uence haracter
^a alert(#ell)
^# #ac'space
^f formfeed
^n newline
^r carriage return^t hori;ontal ta#
^v vertical ta#
^^ #ac'slash
^? +uestion mar'
^G single +uote
^K dou#le +uote
^ooo octal num#er
^$hh he$adecimal num#er
18
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
19/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
^8 null
0) Write a program to print the following pattern!8
1 8 1
2 1 8 1 2
3rogram
.include #stdio'h$
.include #conio'h$main&
/
int a,b,c,d;
clrscr&;
printf0%1d2n3,4&;
printf0%5d2n3,646&;
printf0%7d3,86468&;
getch&;
9
utput4
646
86468
)e#ision Ma.in' & Bran#hin' an 4oo%in'
4) Is it possi#le to use multiple default statements in s:itch&
statement? =o
6) Write the use of else and default statements in if-else ands:itch &statements respectively.
In the if-elsestructure which is 'nown to #e 2,way selection& ta'es care
of true as well as false conditions. It has two #loc's one #loc' is for if
statement and it is e$ecuted when the condition is true. "he other #loc' is for
else statement and it is e$ecuted when the condition is false.
In the s:itch & statements& the default is e$ecuted if none othervalues of the case la#els satisfy the value of the s:itch &constant.
19
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
20/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
7) Why goto statement is avoided?
It is learnt that the gotostatement may let a programming language
a#used. ince in practice& it is always possi#le and easy to write code
without gotostatements& the gotostatements are avoided in view of good
programming practice.
:) Why break statement is essential in s:itch & statement? Whichother functions or 'eywords can #e used in place of the breakstatement.
"he breakstatement causes control to #e transferred out of theswitch
statement& thus preventing more than one group of statements from
#eing e$ecuted.
-8) Is it possi#le to use else statement in place of default or viceversa? =o
-1) an we put default statement anywhere in the s:itch() case
structure? _es. Eut as usual& the breastatement is necessary to #y,
pass to other case la#els.
02) What are the limitations of s:itch&case statement?
very time when a case la#el matches& the corresponding case #loc'
is e$ecuted. In the case,#loc' a breastatement is necessary to e$it
the s:itch which is a limitation.
-) What is a loop? Why it is necessary in the program?
"he concept of a loop is to do an action repeatedly over and over again.
enerally the loop dont stop. We want our program to end when the wor' is
done. "o ma'e sure that the wor' is done& we have a condition that controls
the loop. We must design the loop in such a way that #efore and9or after eachiteration& it chec's to see if it is done. If it is not& it repeats one more time.
"he loops are classified as counter controlledand event controlledloops.
--) What happens if you create a loop that never ends?
"he program never terminates without any user intervention.
-0) Is it possi#le to create a forloop that is never e$ecuted?
_es. If the pre,test condition is false& the loop is never e$ecuted.
-4) Is it possi#le to nest :hileloop within for20
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
21/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
loops? _es
-6) What is the difference #etween (Y8) and (Y1)? How while loop wor'swith these values?
ctually Y8 is 1 and Y1 is a 8.
-7) What is the difference #etween (1D DY1) and (1YD1) ?
Y1 evaluates to 8 so (1DDY1) will #ecome (1DD8) which is false so& (1DDY1)
evaluates to 8. imilarly& in the e$pression& (1YD1)& #oth lhs and rhs of the YD
operator are the same. o the e$pression will evaluate to false and its value
would #e 8. "hough the return the same value of 8& they have different
evaluation se+uence.
UNIT II Part B Questions
1) $plain the different types of operators availa#le in 7
2) What are constants? $plain the various types of constants availa#le 7in
) 5ention the use of breaand continuestatements -
-) $plain the program control structures with e$amples. 4
0) What is meant #y operator precedence? %iscuss its impact in 7
programming with suita#le e$amples.
4) $plain how s:itchstatement differ from ifstatement. 06) Write a program to print the given num#er in reverse. 4
7) $plain any two constructs used for decision ma'ing& #ranching and 14looping statement. ive an e$ample and e$plain the wor'ing of the
construct.
:) Write a program to evaluate the following series 7
18) Write a program in to chec' if the given num#er is prime. 7
11) Write a program to chec' whether the given num#er is palindrome 7
or not.
12) Write a program t generate Ci#onacci series upto 288. 7
1)Write a program in to represent the num#er of years represented #y 14
21
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
22/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
an integer into the following units of time!a) 5inutes
#) Hoursc) %ays
d) 5onths
e) econds.*se switch( ) statement. tate the assumption made in your pro#lem.
1-)Write the synta$ of PforconstructQ in with suita#le e$amples. -
10)Write a program to determine the num#er of and sum of all integers 7
#etween 188 and 288 which are divisi#le #y 6.
UNIT III
Part A Questions an ansers
Arra+s Initia!i(ation/ )e#!aration/ One i$ensiona! an Toi$ensiona! arra+s
1) 5ention the advantages and limitations of arrays
dvantages! while analysing a huge si;e of data& all of them will not #e ofse+uence or integers. o inde$ing these data will help processing #etterand this idea can #e e$tended to multi,dimension. %isadvantages! "hememory si;e for an array can not #e altered after compile time(they arestatic in nature) so e$panding or contracting the
array si;e at run time is a #ig pro#lem in limiting the si;e of the program. o#y considering the worst cases only the si;e of the array is decided sofle$i#ility of program,si;e with respect to small and #ig amount of data isnot possi#le in .
2) What is the relation #etween an array name and an element num#er?How are elements referred using #ase addresses?
Let us consider the following program segment!int a,?,19;
printf0@ase address=%u and its value=%d2n3,a,a
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
23/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
GE6151 COMPUTER PROGRAMMING
QUESTION BANK
/utput!
@ase address=8>?158? and itsvalue=6 second address=8>?158A andits value=8fifth position address=8>?15?4 and its value=1
"he elements can #e referred using a dereferencing operator X. "hat is
X(aA1) is the content of the address of aA1 which corresponds to the
second array position.
) n array name contains #ase address of the array. an wechange the #ase address of the array?
=o. it is done #y the compiler usually at runtime.
-) an we store values and addresses in the same array? $plain.
=o. Here the value at an array address may not accommodate apointer. 3ro#a#ly if we have an array of pointers we can do that.
0) 5ention the difference #etween character array and integer array.
Chara#ter arra+ Inte'er arra+
ach array position occupies It occupies two #ytes
single #yte.
special case of a character array =o such cases e$ist
is called a string which is
terminated #y a ^8 character
4) How does an ordinary varia#le differ from an array definition?n ordinary varia#le will have one value corresponding to it. Eut anarray can have different values assigned at various positions of itsinde$
6) ive the synta$ of declaring a two,dimensional array.
storage-class #data-type$ arrayname
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
24/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
7) $plain multi dimensional array.
"he program allows array of two or multi dimensions. "he compilerdetermines the restriction on it. "he synta$ of multi,dimensional arrayis as
follows. arrayname U1VU 2VU V...U nVF where& i is the si;eof the ith dimension. Cew e$amples are& int matU VU VF intmar's UVUVF
linear inde$ing formula for multi,dimensional arrays that aredeclared as such& e.g. #y int U18VU28V or int UmVUnV
Strin's& Strin' o%erations Strin' Arra+s
:) What are strings? How are they declared?
haracter arrays terminated #y ^8 are called strings.trings are normally used to manipulate the te$t such aswords and sentences. Cor e$ample
char nameU V D PI=%IQF
18) What is =*LL character? Why is it important?
"he =*LL character ^8 is the terminal character in a string array.
11) Is it possi#le to initiali;e =*LL character in the string?
"he last character in a string array is the =*LL character so if thelast character in a character array is not a =*LL character and if itis initialised with a =*LL character then that character array will#ecome a string array.
24
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
25/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
12) 5ention some standard string functions availa#le in .
charstrcats,ct& concatenates source string ctto end of s
returns s.
si"eBt strlencs& %etermines the length of a string
char strcpys,ct& opy string ct to string s return s. 3adwith G8G if ct has fewer than n characters
int strcmpcs, ct& compare string csto string ct,return #4if cs#ct, 4ifcs==ct, or $4 if cs$ct'
In the a#ove ta#le& varia#les sand tare of type char F csand ctare of type const char F n is of type si"eBtF and c is an intconverted to char.
1) Why is it necessary to count =*LL character while declaring
string?
Eecause the total count determines the num#er of array indicesused to store the particular string.
1-) What is the difference #etween the functionsstrcmp &and strncmp&?
strncmps,t,n& is the same as strcmps,t& #ut itcompares onlythe first n characters.
10) What is the difference #etween =*LL& G^8G and 8?
^8 is the escape se+uence in the format specification. 8 is thecorresponding II code for the =*LL character. =*LL is the namein which it is interpreted in nglish in reference to language.
Sortin' Sear#hin' an Matri O%erations14) =ame the different sorting techni+ues availa#le.
hell sort& +uic' sort& insertion sort& radi$ sort and #u##le sort.
16) ive the algorithm for #u##le,sort
Let aU8V&aU1V&...&aUn-1V #e an array declared and initialised in ."he #u##le,sort algorithm can #e shown as #elow!6 for i = 4 to n-6
8 for C= n-6 do:nto i + 6
> if a
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
26/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
? exchange a
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
27/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
6) Write a program to count letters in a se+uence of characters 7
7) %iscuss a#out any eight #uilt,in string9other li#rary functions 7
UNIT IPart A Questions an ansers
0un#tion e"inition o" "un#tion )e#!aration o" "un#tion/ %ass *+,a!ue/ %ass *+ re"eren#e
1) Write the definition of a function. Indicate the types offunctions availa#le in .data-type nametype-6 arg-6, type-8 arg-8, D , type-n arg-n&
where data-typerepresents the data type of the item thatis returned #y the function& namerepresents the function name&and type-6, type-8 D type-n represent the data type of thearg-6, arg-8,D, arg-n respectively. "he data types areassumed to #e of type intif they are not shown e$plicitly.However the omission of the data types is considered poorprogramming practice& even if the data items are integers.
2) How do functions help to reduce the program si;e?
"here are several advantages to modular approach to programdevelopment. Cor e$ample& many programs re+uire that aparticular group of instruction #e accessed repeatedly from severaldifferent places within the program. "he repeated instruction can#e placed within a single function& which can then #e accessed orwhenever it is needed. 5oreover a different set of data can #etransferred to the function each time it is accessed. "hus& the useof a function is to avoid the need of redundant(repeated)
programming of the same instruction.) %ifferentiate #etween li#rary and the user,defined functions
4i*rar+ "un#tions User e"ine "un#tions
"hese are predefined set of %efined #y the user according
functions to re+uirement
"he tas' is limited "he user understands thescope of the function so that
the ideas may #e implemented
27
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
28/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
in the #est way.
-) How does a function wor'? $plain how arguments arepassed and results are returned?
/nce a function is defined and called& it ta'es some data from thecalling function and returns a value to the called function.
"he detail of inner wor'ing of function is un'nown to the rest ofthe program. Whenever a function is called& control passes to thecalled function and the wor'ing of the calling function is stopped.When the e$ecution of the called function is completed& controlreturns #ac' to the calling function and e$ecutes the ne$tstatement.
"he values of the actual arguments passed #y the calling functionare received #y the formal arguments of the called function. "henum#er and type of the actual and formal arguments must #e thesame. ny mismatch will produce une$pected result.
"he function operates on formal arguments and sends #ac' theresult to the calling function. "he return() statement performs thistas'.
0) List any five,li#rary functions and illustrate them with suita#le
e$amples.float po:float,float&;
"he a#ove is the proto type for power function where the firstargument is raised to second power. "hat is $
ywhere $ is first and
y is second argument." = po:?'4,1'4&;
Will cause ; to have 182-.8 assigned. In other words& thea#ove statement returns the value 182-.8 to the calling
module.**void strcatchar ,char&; char x=3abc3,y=3def3;printf0%s3,strcatx,y&&;
will cause Pa#cdefQ to #e printed on the screen.
4) What are actual and formal arguments?
ctual arguments are the parameters of the calling module.Cormal arguments are the parameters of the called module.
6) What is the purpose of return &statement?
28
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
29/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
"his helps function in sending #ac' the results to the calling module.
7) What does it mean if there is no return statement in the function?
Cunctions without return statement is not wrong if the functionreturn a void type otherwise& an error message will #e displayed #y
the compiler.:) What are void functions?
"hey return no value to the calling module.
18) Why is it possi#le to use the same varia#le names for actualand formal arguments?
In the called module however new local varia#les are createdevery time a function is called(e$cept the function has referenceparameters)
11) What is main & function in ? Why is it necessary ineach program? "his is what is first invo'ed #y the compiler tofurther proceed.
12) $plain the different formats of return ( ) statements. Howmany values does return statement return at each call?
"he return statement can #e used in the following ways!
1. returnexpression&;Here e$pression value is returned
to the calling function and if e$pression is omitted return simplytransfers control to the calling function. 2. "here may #e one ortwo return statements in a function. "hey may #e e$ecutedaccording to the condition arising in a program.
1) What is a glo#al pointer? Illustrate with a suita#le e$ample.
=ormally pointers addresses declared outside a function are referredas glo#al pointers with respect to the called functions. onsider!main&/
int a=>,b=?;s:apa,b&; printf0a=%d b=%d3,a,b&;
9
void s:apint m,intn&/ int temp;
temp =m; m =n; n =
temp;9
29
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
30/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
In the a#ove code snippet& the function s:aphas an argument whichis of type pointer to an integer& passed on to the function which isglo#al with respect to the function s:ap.
1-) Why is return statement not necessary when function is
called #y reference?"he reference parameters are transparent to the calling module sothe changes made #y the function will automatically #ecome visi#leto the calling module upon a successful return of the calledfunction.
10) %istinguish #etween function prototype and function
definition(code)?
Cunction prototype is the function declaration where as the function
definition is the actual content of the function statements returnvalues etc..
14) %oes the function prototype match with the function
definition? _es.
16) an we define a user,defined function with the same li#raryfunction name?
=oF #ut if the header file is not included for the particular program&the function name will not conflict so it is allowed only in such
occasion.17) List and e$plain the four scope of varia#les in #rief.
utomatic varia#les(local varia#les)& $ternal varia#les&taticvaria#les
and >egister varia#les
1:) What are automatic9local varia#les?
"hese are defined inside a function. varia#le declared inside a function
without a storage class name& #y default is an auto varia#le. "he scope ofthe varia#le is local to the #loc' in which they are defined. "hese
varia#les are availa#le only to the current #loc' or program. /nce the
e$ecution of the function ta'es place and return turns off function& the
contents and the e$istence of the auto varia#les or local varia#les vanish.
28) %istinguish #etween static and e$ternal varia#les?
Stati# ,aria*!e Eterna! ,aria*!e
"he static may #e of internal $ternal varia#les are
or e$ternal type& depending declared outside the function
30
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
31/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
upon where it is declared #ody.
It is initialised only once. If #oth e$ternal and auto
varia#les are declared withthe same name in a program&
the first priority is given to
auto varia#le.
"he value of static varia#le
persists on each call and thelast change made remains
throughout the program
e$ecution.
21) an we declare a varia#le in different scopes with differentdata types? nswer in detail
22) What is calling #y reference in ?
In this method& the addresses of the actual arguments are passed tothe formal parameters of the function.
2) ive an e$ample for a function returning a pointer
"he following function gets an integer #etween 1 and 12 and returnsthe pointer to month name.* monthBname return name of n-th month* char monthBnameint n&
/
static char name
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
32/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
string are placed somewhere& and a pointer to them is stored in
name?,>'?1,?'15,1'57,4'49; ptr = "ilch;
32
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
33/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
:hile ptr != 4'4&/
printfENhe value stored at address %u is %f2nE,ptr,ptr&;
ptr++;
99
"he output would #e
Nhe value stored at address ?6?? is6'8>4444 Nhe value stored at address ?6?Ais 8'>?4444 Nhe value stored at address?618 is >'?14444 Nhe value stored ataddress ?615 is ?'154444 Nhe value stored
at address ?654 is 1'574444=ote the intervals #etween the address now. "hey are each -. /urreferences computer addresses its memory #yte #y #yte& and an intta'es up two #ytes where as a floatuses four. "he same case appliestoB operator as well.
26) $plain the relation #etween an array anda pointer. onsider the declarion!
int prime
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
34/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
used as pointers X9
ptr; 9X 3ointer addition iscommutative X98
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
35/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
structtag/ Hember6;Hember 8;
'''Hember m;9;
In this declaration structis a re+uired 'eywordF tagis the name thatidentifies this typeF member 6& member 8... member mareindividual mem#er declarations.
2)How are structure elements stored in memory?onsider the declaration shown ne$t page!struct student
/
char name4;int rollno;float height;
9;
35
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
36/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.I
GE6151 COMPUTER PROGRAMMING
QUESTION BANK
studnt1nameU8V
rollno
height
struct studnt6 student;
"he a#ove declaration creates varia#les studnt6of structure type studentand it reserves a total of 4 #ytes(8 for thename4& 2#ytes for therollnowhich is an integer and - #ytes for floatheight)
)$plain nested structure.We can ta'e any data type for declaring structure mem#ers li'e int& float&char& and so on. In the same way& we can also ta'e o#Ject ofone structure asmem#ers in another structure. "hus& structure within structure can #e used tocreate comple$ data applications. ee #elow struct date/
int dd; int mm;int yyyy;
9;struct employee/
char name4; structdob date; struct doCdate;
9;
struct cse_emp employee;
"he a#ove e$ample shows how structure within structure is declared and it36
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
37/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.I
can #e visualised as follows!
cse`emp
nameU8V
do#
dd
mm
yyyy
doJ
dd
mm
yyyy
-)What are aggregate types?
"he structure is a 'ind of aggregate data type in which is nothing #ut aderived data type.
0) an a structure have a pointer to itself?
onsider the following declaration for a node in a #inary tree. Let us say thenode has a value which is of type integer and as it is a #inary tree a node mayhave two pointers pointing to two other nodes. "his can #e represented as!struct Xnode
Nint valueF
struct node Xchild1&Xchild2F
O
4) How is the declaration struct typeN...OF different from typedef struct N...OF?Ey using typedefwe can create new data type. "he statement typedef
is to #e used while defining the new data type. "he synta$ is as given #elow!typedef type dataname;
37
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
38/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.I
Here& type is the data type and dataname is the user,defined name forthat type.
typedef int hours;
Here& hours is another name for int and now we can use hours instead of intin the declaration as given #elow!
typedef int hours;hours hrs;
6)How to 'eep trac' of which field of a union is in use?
In it is not possi#le to 'now what type is currently stored in union.7)What are the differences #etween a sym#olic constant and an enumeration
constant?
enumeration constant sym#olic constant
numerations are uni+ue types that .defineline defines a
have integral valuesF associated with sym#olic name or sym#oliceach enumeration is a set of named constant to #e a particular string
constants. numerations #ehave li'e of characters!
integers& #ut it is common for a .define name replacement listcompiler to issue a warning when an
o#Ject of a particular enumeration is $ample!assigned something other than one .define HIP 644
of its constants& or an e$pression of
its type.$ample!enum months /FIJ=6, GQ@,
HIR, ISR, HIT, FUJ, FUV, IUW,
(QS, N, JX, KQ9;=ow the value of 5_ would #e 0 #ut
if we say
enum months /FIJ, GQ@, HIR,
ISR=644, HIT, FUJ, FUV,IUW, (QS, N, JX, KQ9;
the value of HITwould #e 646#ut the
value of FIJwould #e 4
:)What are the various stages a program undergoes #efore $ecution?
38
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
39/41
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
"he various stages a program undergoes #efore e$ecution are!1."ranslation 2.Loading
"he various parts of translation are!1.3reprocessing 2.ompilation .Lin'ing
ource3rogram
3reprocessor
implified 3rogram
ource Li#raries ompiler
(.o#J Ciles) /#Ject ode(.o#J Cile)
Lin'er>elocata#le e$ecuta#le
ode (.e$e Cile)
Loader
ddress #inding and
e$ecution
"ranslation
Loading
39
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
40/41
18)What is a macro? What are o#Ject li'e macros and function li'e macros?3reprocessor directives such as define are used at the #eginning of the program to define constants or any macro su#stitution..define #identifier$ #replacement toen list$
99 "he a#ove one is an o#Ject,li'e macro.define #identifier$#parameter list$& #replacement toen list$
99 "he a#ove is a function,li'e macro& note parameters
"he function,li'e macro declaration must not have any whitespace#etween the identifier and the first& opening& parenthesis. If whitespace ispresent& the macro will #e interpreted as o#Ject,li'e with everythingstarting from the first parenthesis added to the to'en list.
11)What is the role of the error directive?.error ESl' specify build type in the HaefileE
When the preprocessor hits the .errordirective& it will report the stringas an error message and halt compilationF what e$actly the error messageloo's li'e depends on the compiler.
12)What is the role of the pragma directive?
"he pragma directive is the method specified #y the standard forproviding additional information to the compiler& #eyond what isconveyed in the language itself. n unrecognised pragma is ignored #ythe compiler.
UNIT Bi' Questions
1) What is a structure? How does a structure differ from an array? 4
2) How an array of structure is initialised? 4) How a structure mem#er is accessed? 4
-) $plain a#out structures and unions with suita#le e$amples. 4
0) Write short notes on 3re,processor directives 4
4) %efine a structure with tag population with fields 5en and 7
Women. reate structure within structure using state and
population structure. >ead and display the data.
6) Write a program to define structure with tag state& with fields 7
state name& num#er of districts and total population. >ead anddisplay the data.
7) Write a program to accept records of 28 states using array of 14
structures. "he structure should contain name of the state and
num#er of engineering colleges& medical colleges& management
colleges& science colleges. alculate and display the total collegesin each state which is having the highest num#er of colleges
-
7/24/2019 QUESTION BANK FOR COMPUTER PROGRAMING REGULATION 2013
41/41