0% found this document useful (0 votes)
27 views

CS Fall 2022

Past Papers

Uploaded by

laibaakbar015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
27 views

CS Fall 2022

Past Papers

Uploaded by

laibaakbar015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
UNIVERSITY OF THE ‘gS. ln Computer Science Second Some UNUAB tor ~ Spring 2022 Programming Fundamantats Paper Coat s WERE IE ATTEMP” IE ANSWi Q4, Write short note on the following: ‘ Conuider tha tollowing code, What wil be the Plt to the console when the \Reration f for loop rune? © Include «vtdle.hy © kaclode «ateing.hy- oid dtsplay(int vy (6x5=30) vecond vn mating) hat vers; atiatvce & von) Hsplay(vy Print t ("xe w--) prinet(sjp return ¢; ) 3% Wow martes tr boop athe toowing program wil exsexte? eh 3 Suppose you have an aray:int s20{4I2} « (22.,11,2 }, What wil be the eutput (Of printfa" arr2D [1]; 4 Wehat will be the evtput of the following program? # include estdio,h> # Include Ant maln() File “Files char cf400)i (ile wtopeetetiiele yw), elds Ertugral ix a turkish historical fiction”); felove(file); file = fopen("file. ‘freek(File, 3, StEK_SET); frcant( File, printh(“Ra",c)y, return 0; Page 1013 PTO. (59 CamScannet * panto he ott of the fll Porat 5 eatdia.o ‘oa or tent) Uae aaa eden asnzitelt ink Sh ae are retarn 05 . ’ - 9 [ «cont teflon ce Hiern ts qeseute? ide the while foo Mt # dnclode cstdio.hs w include catring-}> i maint) Sat ast, bay ietilefanie) peintf("w\n") if(o—b) bebo ie anh{b-a)al return 8) ) f ws Q.2, Answer the following questions. Part a ‘Welte C program that raives the Sti problem Consider the fllowing alprtha to generale wvequnnee Of umber. Start with an integer n. If ts even, divida by 2, ifm is odd, multiply by 3 and add |, Repeat this ‘Process with themew value of, terminsting whea 2 1. For example, the following feqoence of mumbers wil bo generated for n = 22: 22114 1752 26 134020105 16842.) Foran input, the cysis-leagth of n is the number of rumbers generated up to anc (naluding the 1. In tho example above, the cycle length of 22 is 16. Given any two mutes (und), you are to determine the muximum eyclo agth aver all numbers ‘even an aig oth epi, Tee pet wll const oF series of paca tego ahj-cat fof nteges Hi. integer wil beat than 1,000,000 and greta tn 0. ™ ‘Foren pa oflapit lateper ian, outta det rotor pet tacze oer fn which Dey nia Thr tom te hl eee one i i Ot ‘oes low mad with one lin af antpat for enc line of gph. Feassple Input 110 100 200 201210 900 1000 | Sample Output 11020 100 200 125 20121089 900 1000 174 Part B For each of the following, write C statements that perforan the speciffed ALDeciere a built-in array of type int called valves with five elements, and ‘the even imogers trom 2 to 10, Assume thatthe constant SIZE has bees Bae Pointer vPtr that points to-an object af type tnalgned int. Ses ‘Stterentto display the elements of bul-in tray values using array subscript AL Write to separmt statements thet antiga tho stuting sddress of builtin array values ‘to pointer variable vPtr, ££) Uses for statement to display the clements of bult-ingrray values using pointce/ottiet £1 Usea for statement to display the elements of buill-is brray values using pointee/affoet ‘notation with the built-in errey's mame us the pointer, 8) Use 1 for statement to display the elements of ‘valuze by subscsipting the pointer “he built-in array, eee _ ° ‘task, initialize the elements to defined as 5, Partc Write a © program that prints the following pattern on the screen, You rust use nested loops otherwise ZERO will be awarded, 1 6 16 31 51 76 egeueer Beene RRERER* geapes gaeeRe , —+ page 30f 3 B camscamer

You might also like