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

C Assignment

Uploaded by

udaykiran.adama
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)
14 views

C Assignment

Uploaded by

udaykiran.adama
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/ 14
101123, 4:54 PM Module 1 Exercises -Colaboratory + Module 1 Exercises Double-click (or ents) to eat + Develop a calculator to convert from one unit o another atime 2.Distance 3. Temperatuere prancé("Enter the runner of seconds: "Ds Seant°¥a", seconds); hours = (dubte) seconds / 3600 prsnee(s seconds 45 equal to HF hours\n", seconds, hours) 7200 seconds is equal to 2.680688 hours se san9-690 int main() pears Kian ries ~ kon prinef CXF kitoneters Ss equal to Xf ailes\n", kiloneters, ales); overwriting san. 7a.out fine rain) prinee(veetesus: ")3 SeareMF, Beclesus) (CMF coleturs ts equal to Hf kelvin\n", celetus, Kelvin)s hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true a 1011723, 4:54 Pa Module 1 Exercises -Colaboratory overwriting san. celeiuss 38 35000000 celciurs 1s equal to 389.24399¢ kelvin + Simple interest int rain) cipal, rate, princé("Enten principal aunt (9): "Ds Feant CX, Aprinetpal)s print#(‘Enter rate of interest (8): ")i Seare(rx, arate); prante(“Enter tine period in years (1): “ds Scart("xe", tine): sinple_interest = (principal * rate * tine) / 200; printe("Sinple Interest: Xf\a", simple interest); lvenunst ine sanp.cop ace Son -cpP Vacout Enter prinetpal amount (P): 10080 Enter rate of anterest (RD! 7 Enter tine period in years (1): 2 + Calculate the total marks, average and percentage ofthe 5 subjects, sre maint) ish, Nathenatics, Prysics, Chenistry, Programming: prince ("Enten marks for English scart", AEnglish) prines(-Enten marks for Mathenaties: Sears("Aa", satnenaties); printé("Enten marks for Physics: Scant%a", APhysies); prinee("Enten mares for Chensstry: ")s Scare, achensstey); prante(-Enten mares for Programing Seart("%a", aprogranning): matics + Physics + Chantstry + Programing: average = total 5.23 hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true ana 1011723, 4:54 Pa Module 1 Exercises -Colaboratory percentage = (total /(S.8 * 100)) * 3085 prinee(cTotat Marks: 44\n", total); pranee(caverage Marks: FW", average); print#( Percentage: 2¢\0 Enter marks for cnenistry: 87 Enter marks for, roptannan® 98 average Mares: 98.800003 + Calculate the net salary ofan employee given basic, daha, pf and others. neladecstiorh> ne rain) prince(“enter sasic Salary (S) Sean basic); princecenter Ha (8): “D3 eaneX thea); printe(“enter TA (8): °) Sean" ata); printe(*enter others (8): "): Sean" botners); f= (boste+22)/200; Jesleutate PF 16% of baste salary p= (baster24)/200; Jfealeulate 11, 19% of baste salary toasters} 206; rotisalary = Basie 4 da ¢ hea ¥ ta ¥ others = (fest); Liprincing Net sa prsnee Cnet SS! $ KeDAO" nets ays Enter Ha (= 1000 Enter TA (S)? 2500 Enter others (8)" 5008 ‘+ Retrieve remainder after dvision of two numbers without using mod operator. hitps:lleolab research google.convrive1cFq StUaRFZESKTYATLOGSXKadKtA2sprintMode=true ana 1011723, 4:54 Pa Module 1 Exercises -Colaboratory soinsé("Enten the obvidens: “5 prines("Entan the aivisor: “)s seant(MG", Advisor) 1) Calculate the remainder insle (rensinder >» etvisor) > prsnes( Remainder: 2e\n", renasnder) + Convert an upper-case character to a lower-case character, Sint main() enor upper case thar, lowercase char prént#("Enter an uppercase character: °)s Scart(” He", Rupper_case_char); ry 46 (upper cae 11 Convert Lowercase by adding 32 to the AS Ae\n", Lower case. Chae): > prine(“input 45 not an uppercase character.\n")s overting san. + Swap two numbers int maint) pranté("Entar the value of x: “)i hitps:lleolab research google.convrive1cFq StUaRFZESKTYATLOGSXKadKtA2sprintMode=true ana 1011723, 4:54 Pa scant Re, ods printf ("Enter the value of 5 “2s Seare(Ma", &) princf(cArcen sanpping:\n")s printf'x = K8\n"s 9) printeCy = Xa\8", 9) verentt ang sanp.cop ce song cpp Va.out Enter she value of yi 38 + Enter wo angles ofa triangle and find the third angle int main() ‘oat anglen, angle2, angie rant e-em Scart°R¢", banglel): yt angle: *); printé(‘Enter the measure of the second angle: “s cant Xr", dangle?) Enter the maasure of the first angle: 42 The measure of the third angle 1s; 69,609000 degrees ‘+ Check Least Significant it (LSB) of a number princf("Enten any members °)3 Feanf(%a", non); (Jf (oun & 3) evaluates t0.2*7 Se(run 8) PrInt(PUSB Of Me Ge set (2).", nu); Printt("USB of Ra Ss unset (@)-"5 num); Module 1 Exercises -Colaboratory + angles): hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true sna 1011723, 4:54 Pa Module 1 Exercises -Colaboratory Se or a8 is set (2) ‘Check whether the angles equilateral, 'soscetes, or scalene triangle. int main() the Lengths of three sides of a triangle:\n"); Scant ("Ma 4 Re", ASiaed, Msiée2, 453003); 46 (sider = stoe2 ah side? =» sta03) print" is an equilateral trésngle.\n"); > else 1 (siden == seed || sigez = stdea || sidet => sides) printe(*re 45 an Ssosceles trsangle.\n")s printe("tt ts a scalene tetangle.\9")5 + Check whether entered years a leap year or not safle samp.c90 sincluce ceteto.h> ine main() prsnes(enten a years“) 16 ((year % 4 20 @ 48 year % 160 I= 0) || (year X 480 = 8) Print (Kd ts 3 leap year-\n", yoar)s ? peint('Ad 15 not a Leap year.\n"s year): hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true ena 1011723, 4:54 Pa Module 1 Exercises -Colaboratory Enter 2 year 975 48 hot a + Find minimum among tree numbers Double-click (or enter) to eat prine("Enten three Mnben\n"); see) ‘ (ace) print#("Saaldest Number Ss: R4",sn031); ce an cop + Check whether a numbers chisible by Sand 11 or not pranse(venter an inte Scont(Ha", dnenber}; 4 (ounber X 5 <= @ BB nunber X 11 == @) print("Ad Ls divisible by bath 5 and 21.0", mumber): , Print(Xd £5 not divisible by both § and 31.\n", manber)s hitps:lleolab research google.convrive1cFq StUaRFZESKTYATLOGSXKadKtA2sprintMode=true 74 1011723, 4:54 Pa Module 1 Exercises -Colaboratory verrdting samp + Design a calculator that performs arithmetic operations on two numbers using switch case print ("tn eant (Ma, Ano » ssten (namer > 0) { print("The number is positive.\n")s switch (number 8) prinee(the number $5 negative. \e")s overwting san. yacout + Find factorial of a number printf("Enten 2 nunber to find factoria scant" in): For ences prinst(*Factonsal of #4 Sst K6",9,f00%)s hitps:lleolab research google.convrive1cFq StUaRFZESKTYATLOGSXKadKtA2sprintMode=true ana 1011723, 4:54 Pa overrtting samp ‘+ Check whether numbers @ palindrome or not prancé(enter the nino cant (Xs vinste(way sun=(Sun0) 605 ettengeesun) prinee(-palindrare runber *)3 prinee(°net paltadrone”)s + Check whether numbers perfecto: not sng wain() printe("Enten any runter te check perfect unter: Seore("4e", Bun forth = a5 4 = nun / 25 249) s4¢nunsi == 6) ‘ > s¢toun = nue AB mun > 0) print('Kd 15 PERFECT NABER", nun); Print(Kd Le HOF PERFECT MAMMER", nu); Module 1 Exercises -Colaboratory hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true ona 1011723, 4:54 Pa venwntt ing samp. cop + Convert a decimal number to binary number prereé(center 9 decsnal morgen? "); Feant ("Ma Asecina]_nun) sntte (decinal_nur = @) bo; . prinee("Binary nurbers Xan", Binary_nun); Jacout + Print folowing patterns int main() orinté("Enter the number of cous: “): Scant °%0", Brows): for (unt $= ‘ prince yeu se rant" ce sanp.cpP Vacout Module 1 Exercises -Colaboratory 2, rensinders hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true ron 1011723, 4:54 Pa Module 1 Exercises -Colaboratory int main(), printe(-Enten the number of 2656s: "); reant%a", an), for (int $a; bee ns So) for (unt $= printeCke *, current. chars printe(e", current. char), printers overwriting sanp.cop Enter the number of Lines! 12 printf ("Enter the number of ous: “3s Scant MA", an) for (unt 5 t prinee("xd "5 munber)s ? Printer) hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true nna 1011723, 4:54 Pa Module 1 Exercises -Colaboratory -* Calculate the greatest common divisor of two numbers fine ot, 92, 4, Beds printf ("Enter to Srtegers Seared as", Set, Bea); For (iat; £ ce mt kL ce m2; 48) (nitie=o 8 nzklon0) ) print#("6.C.0 of Rd and KE 1s 84", ny 2, ee8)s Cvenentt ang sanp.cop ce Sanp cpp + Generate frst n numbers inthe Fibonace! series int main() prineé("Enten the runner of terns: ")s Scant (Ma, ns print#("Flbanaced Sertes: Wd, Bd, © for (15 3; Lees HH) printed, ", next Term) yacout hitps:lleolab research google.convrive1cFq StUaRFZESKTYATLOGSXKadKtA2sprintMode=true vane 1011723, 4:54 Pa Module 1 Exercises -Colaboratory + Swap two numbers using pointers ine main(), pranes("Enten the value of x and yin") Seane(rdee", 8x, 69) rine ("Before Swapptng\nx = KB\ay = 94\n", x, yBi ant CAFR Suappng\nK = Kd\ny = HE\N, Xs DE + Performs all the five arithmetie operations using Pointers arinté(enter the operator synbol:"}: cant” Ae, lop); ssten (on) Print ("adéition = a, #2 + *p2)s print(*aubetraction =", tpt = *92); print(waltiply = 4", tet * *p2); F(a I= 9) ‘ print (‘division = Ma", ¢pt / #92); ‘ printe(“étviston by zero 1s not allowed”); hntps:lleolab research google.convrive1DcF q StUaRFZESKTYATLOGSXKadKtA2sprntMode=true ran 1011723, 4:54 Pa case 'X':printf(Srenainder = Xd", tpt *p2)5 hntps:ilolab research google. conicrive DoF 9 StUaRFZ6SKTVATLOGSXkadKiA2sprniMode=true Module 1 Exercises - Colaborstory sana

You might also like