You are on page 1of 2

Lab -- 5

IT 105 Introduction to Programming


2011-Autumn

Instructions:
1.Attemptallquestions,andgetyourselfevaluatedforthemthroughaTA.
2.Youmayuseonlythemanual(ie,`man`)foryourhelp.(NoInternetplease!)

SectionA:
1. Armstrongnumber:153=1^3+5^3+3^3
a.writeaprogramtocheckwhetherthegivennumberisarmstrongnumber
2. writeafunctiontoprinttheseriesgivenbelow
foragivennumberabcdithastoprint
1123581321345589144233377610987
thedigitwhichithastoprintshouldbethesumofitsprevioustwonumbers.lastnumberinthe
seriesshouldbelessthanthegivennumberabcd
3. aclassof5studentstakeanannualexaminationin3subjects.writeaprogramtoreadthemarks
obtainedbyeachstudentinvarioussubjectsandtocomputeandprintthetotalmarksobtained
byeachofthemandalsothegradeofthestudenttowhichhebelongs
4. Anelectricpowerdistributioncompanychargesitsdomesticconsumersasfollows
ConsumptionunitsRateofcharge
0200Rs.0.50perunit
201400Rs.100plusRs.0.65perunitexcess200
401600Rs.230plusRs.0.80perunitexcess400
601andaboveRs.390plusRs.1.00perunitexcess600
Theprogramreadsthecustomernumberandpowerconsumedandprintstheamounttobepaid
bythecustomer
5. Afterunderstandingtheconceptsgiveninlectureslidestrytofinderrorsifanyineachofthe
followingloopingsegments.Assumethatallthevariableshavebeendeclaredandassigned
values

a.while(count!=10);
{count=1;
sum=sum+x;
count=count+1;}
b.name=0;
do{

name=name+1;
printf(MynameisJohn\n);}
while(name=1)
c.do:
total=total+value;
scanf(%f,&value);
while(value!=999);
d.for(x=1,x>10;x=x+1)
{
***********
***********}
e.m=1
n=0
for(m+n<19;++n);
printf(hello\n);
m=m+10
f.for(p=10;p>0;)
p=p1;
printf(%f,p);

You might also like