0 ratings0% found this document useful (0 votes) 48 views13 pagesMCS-011 Problem Solving and Programming
Assignment MCS-011 Problem Solving and Programming
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
PROGRAMME TITLE 2 PosT GRADUATE DIPLOMA ( ComPUTER APPLICATION <)
COURSE Cope: Mics-O1L
COURSE TITLE: PROBLEM SOLVING AND PROGRAMMING
ASSIGNMENT Cope: PGDCACI)/ O1L1L/ ASSLGNMENT/2020
STUDY CENTRE 21315 KARNATAKA REGIONAL ENGG- COLL C1ZisP)
ENROLMENT No. : 2000 769492
NAME 4 ROWIT KUMAR
ADDRESS 1 MERU AADHITAPARTS, FLATH 204, SILVER SPRING LAYOUT, BANGALORE-
SIGNATURE 4 REHIT Kumar, **
DATE 2 02/05/2020
Scanned with CamScanner4 i .
Qt tavite the following functions’: tha:
A) Requett the user for +0 infegers and outpule tham and tarcum,
+) Requost the user for hoo wiegert and outbutg their vemindar after
division:
) Requoxt the user for two floats and oxtpub nese product:
A) Raquest the User for a worcdl and pringe Fb bvice on Me somrow,
Kivite a © program to provide ene, above. fenctarg as options, to +
the user “ting switch stogement and performs tre funcheng
accorching ty +
Are: detndusda ¢Sishiorh7
Void add—two-Me Cvoid) 5
Void divide two- 0 void);
Void product two-worvord
Void tnren— word Cvoid) ;
mt main (>
printt Clandly select below options to porter task \n");
printf (loprion 1: To Know Sum of tus Unteger th");
peintt (Yoprien2:Te Know reminder of two Urieger \n" );
pruntt U' Option 21 To Know product Of two float Ww")!
pemrf Cophen 4? To want te print a word tie \n"):
wr optien +
scant ("7d Zoprion?
switch Coptien)
t
easel t
case2 7:
cose 3%
Cose 4 4%
defautt +
add wo no 0);
prank >
duvide two. 0;
beank: .
product two 100? }
break;
Aurea — worl ©
rank ;
prmtf. C' You have entered Lnvalicl option”);
break;
Scanned with CamScanner7 Fanction for quastion t-tay-#/
Void odd _two~noCvoid)
R
rt nwrnt, mur;
print andly enter frat nutes \4") 7
Scant yd”, arms ); ee
pemntf C kandly enier second number \% );
Sconf ("LAY pe nium 2) *
printf sum of two numbers hd ond Pa te Td, \.
numl, nmr, (numi+ mum2) D>
3
/* funchen for quaitien 16) */
void clividle —t90-n0 (void )
nk num , nun? +
brinth erally enter Gat number \w'):
Stanf Utd Anum) |
printf (icindly euntey seco
Seomf. (NLA tery)
parte Co Pamindar of too mumbers ed ond td tA,
numd, num, Crom num2) ) 7
ng number 1");
&
/& fonction for quattion 1.C0) a/
Void product two-no Cyoid)
x Hoot 44, £2; 1
printf (" wanelly eater Brash number \w" J)
SER EL);
CE RSIy enter second rere WN");
seat OME LAD)” /
pants’ product of two naumberys Pf and /-t WE "\,
HL, Er(Ldowrle) (ELRED)) ) 7
$
fe function for quation Ld) */
void poica esol void )
q
be chor st¥LSol >
printt Ut windy enter a w
Stand (875% este);
ort Wn");
Scanned with CamScannerParte Were te worl 2465 7.65 Str sr) 5
3
@2 dette an algoritnm draw a covresbonsting flowchast and write
on inlerackve program to convert a binary number’ to ie
alacimo! equivalent +
Algorithm:
steps s
1. Stash
2- Read the brary number 1:
3: Linitiatize J
doc num £0, bore <1
Repeat StepS through 8 unl n=0-
wam — ny-10-
bose
ac nun c che c Nb OD Ae D :
4.
s
@
ee ND en/rw-
QB. bose < boaeth.
aA.
prmr doc nm!
yor Stabe
Program 3
Aeincluda csthioh 7
ge unckuda 4 masn:n7
wnt convert (Long NEN Dy
unt main) ,
£
tong long 7} a
beet vanetly enter & Ismary nexber 2 Vw oi
Seanf (“Yat "6 7
promt ts 7, Gad wm Binary 27d ty decimal /)
N- Convert (n) ) 5
£
Unt convert CL bong bongn/
int dac=0 ,2
=O, rem;
Scanned with CamScanneri
| while Co 1 =0)
4
yom =n7.10!
nensno;
dac = dee + (vem * powt2,2)) }
ari g
z
rerun dae;
z
Flow chart :
START
GET BINARY No. &
D=D+ Rk o*Power|
7]
Scanned with CamScannerQ2 Leite te following feenctions that + : .
O) Request tha user toMpur a S digit number and reverse the
gre number and prinkit:
b) Request the user to Inpuh to floats ond outhute
Of the wpuda:
©) Requast tha user to inp
divisible by +005 divide 2t by TO other wise, moh
three cand output tha result
A) Raquost tha user for tres tiegers ond output eohethar ong of
tham cere equals Use only if-else stetement
the largest
ran mbeger ond rf te number &
plies it by
cla. the. above feenctions o3 ‘oprien . to tha
Lirile a C program to provi
form tha fanchens accordingly.
user Using suoitch statement anal fer
ARuncluda
3
7 function for quotten 2Cb) +/
void ‘fend largert_muim Cod)
© proot 4, £2 rlargestnun +
printf CU Emtes roo Hats “ith a Comma 2 nl):
Sconk (Ph Th" Moft, pay :
Largest rer = (E1762) 2 Espa
Print£U Largah number betoesn thare is fy torgextuen) 7
Scanned with CamScanner/k function for quastion 2L0 #/
Void find-ewven-num (void)
unk num, result;
Poof Cl Enter a number %n") ;
Scart O'Ta", wmuen) :
He (numy2 = 207
vresult} =nurn/2 >
Ase
result = nur 3 5
Printf O' The vesutbis 7k", result J:
3
(& fnction for quaitien atl) ”/
Void fend ogqual_ num Woia )
£
ih numi, numr, numa ;
prmtf 0" Enter three Number separ
Sr (“Yd wd 7nd”
tf ( Mun =
oted by comma AW
7 ema 1, £m, nua) s
brintf CAE least foo numbers are egal )y
else,
Printf ChAM number are entquairy:
Q4 Krite a program Wh recoly characte from & String and
Colaodes Ene number of Vowels ty it. TH shouted Print the
String and tha Number of vowels mip,
Piimcluda CStehigsh >
# include Csteung-hr
‘mt maine)’
2
char word (100) +
int Length, toto! =0 >
Scanned with CamScannerprint} ( Enter a word 2\n") >
Sconf (“7s g word),
length = Strlen (word) >
for (mt L205 idtengtn; itt)
Switch( word C21)
cose *O »
cose SAI
totol ++ 5
break ;
5
brint£ (OS Word ts entered by user ig 27.8", word) 5
printt CA, total vowel avaitoble m word & 2 7.d", total) >
Z ,
Scanned with CamScannerQs Following & the Toylor-Sesiey expansion for sintx):
Sm) = x- x73) e xs ye RVaLE
Litite a program tnot ready a vatuo of X and Caluttatessin(x)
MSing the firat LO terms only and printe tout the resubbs
FP imclude
Strack Stexdewsde
2
int rollno 5
Chaos nome Cal;
Wor masts[sy:
int toto ;
oat og
Stud [204 ;
&
maint)
eke
Pkt C Enter Number of students 7):
Sean 7d", £075
foe Cizoy 245 244)
z printf Enters roll numbers \w!)>
Stank ( 7.d",¢ Stud Cij-rollno) »
prmtf Center nome of tha Studan + \n") 7
Seark("%S", C stl A] nome):
printf Center marks un Gach sblect iy below format 2//
printf Mes-on, Mes-o1, MCS-0I3, Mes-014, Mes OS Wn” >
Seon Fd, 7.5, I-A, Zh Td” 7k Std [44- martg
catad (E]-morks Cid asiod sd warksL2)
&£ Sted [iJ- marta, (39, esteelfag - smarty Cay -
Stud (iJ - total =9
Sor (int js05 jeg + Lh+4)
$
Srad [id -toto) = Stuct C21-tota) + Stead £2] - mara Ly.
g
Stud (2d -owg = Studd C43-tot/ 5-05
BN
Scanned with CamScannerprinthO in Rall NoLE Nome \e Mes-Oll YE MCs—O12 VE Meg-O12 \e\
MCS~OId\E Meg-D1E\t Total Vt Average \n Ww);
for (iso; tan 5 ins)
z y ”
bint Ord te 2s wd vt Ld te 7d Xe ZA Td PANE 7-4 0
Stud [iJ -rollno, Stud [éI-name Sted [3J- Morkslot,
Stud Li} -marea[1], Stelle. max ks[e , stect [2] masks T23,
Studley. macts (4), Sad [ed- toad, stadt] 0”) 7
4
Qt Writ ac Progrown ¢
@) To gererote 10 rondom numbers between lS ond 1-S and
worites them im a file ron-dot.
(b) Ta read tne data from the file ron dat (Creste above) and Com buhay
the asc of tha dota + Tt alxo fnela tho number Of Aata
ebore the average valu.
feincludadstdio ny
# include 4stdtib b>
HE Wcude Cteme-h>
J) function to generote random
Void coriteRandnma ( float lower ,fLoat ubber 4 Unt count)
naw ber 1
t File * Fpws
Fp = fopen CY yum. tetle Nw’) +
mt iso
for ( 220 7 icoount ; ir)
© loot mun =(epber lower) A CER 9 oo ) rome) / RAND-MAX)E
lower |
£ prrf C&pes, Spf We", mum ) 7
¥
Lele (EPO) 5
3
Scanned with CamScannerII tunction to read dnd Rnd overage //
Void veadRondome (void)
4
FILE KE pw >
double total =0;
Reo = fopen Wan teh, SDS
float num C10) +
for (amt iso; igto’y inn)
fscont ( ¢paa,! 74!" & umd) 3
totol = total t(double) nm [iT +
z
double tot-ovq = totat/1o
benrt (Wn The average of random number t Tf, tot -OWG) 5
wt pegh-Cor £0;
for (tint 2207 2210 ;EH)
Lie ( numcis > roto)
high zcor t+;
’
printf (The total nos beghex Hoon average +
felase CFP) +
g
13", Drqh-wr);
Hf Deiver
bm Condo //
imt main 0)
t Float lower = Ls, Ubbee = 5
int count =195
Srand ( time l0)):
warite Rondom: (lower,
vesdRandom: (25
verron 05
ub ber, Count):
Scanned with CamScanner