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

SOUGATA SOO_ME_22_Computer Language Lab Assignment 1

The document contains a series of programming assignments related to mechanical engineering, focusing on basic programming tasks in C such as printing messages, swapping integers, checking for leap years, and identifying palindromes. Each assignment includes code snippets and expected outputs, demonstrating fundamental programming concepts. The assignments are structured to help students practice and apply their coding skills in various scenarios.

Uploaded by

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

SOUGATA SOO_ME_22_Computer Language Lab Assignment 1

The document contains a series of programming assignments related to mechanical engineering, focusing on basic programming tasks in C such as printing messages, swapping integers, checking for leap years, and identifying palindromes. Each assignment includes code snippets and expected outputs, demonstrating fundamental programming concepts. The assignments are structured to help students practice and apply their coding skills in various scenarios.

Uploaded by

bssphoenixphp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

UALIAIGURT GOVRUMENT

ENGXN EhING ÇOLLEGI


HUTONOrOUS
NAME- SodGFTA Soo
ROLL21101103022
BHTCH-2021-25
GoryPUTER LFNGUPGE LAB
H6SIGNMENT 1
MEGHANICAL
ENGINEERING
VAY-1

OWEle a
to paiut "Hello wlosl
progam
An
Einclude etolio.h
it MAn )

f (Hdlo Wovl");
heturn 0

Outu
Hello Woxld

2 ste a
prhgsam to 2wap oo intege humbex
Vasiable
As E ntude stdto.h

loat vs, eLond, temp


Pat.f(" Ente frst abex:");
Bcaf "f", ftet);
stf f" Ewter Seond wumbe:")
tcun ",%esond)
temp f t
ft3euond
ReLon t p
pttf ("\n Aftex Awspfat
RA Hex Bwappi Beond numbe
. f , uono );
Aeturn 0

(b)wthoet uting tad yarial-le


A E nude ( s4do. h)
fTMAn)

Hoat a,b;
prtf"Eter a:") ;
ennf "f, k)
eit Entebb:);
Can (%f,'kL);
a = a-b

atb
ab-a
I

pt f (lex Aweppia,a -2f\n


Psnt a

pt-tf("Afe tuapp3,b- 2.2f",L)


Aeturn O

Outpu
U dvariable;
umber: : 4
Entex Beconod wumwbex F

Aftes swapping u t mber: 7.0oo


Afts Ruappin2eono nuber 4.00
( ctout ug tRsd voable ;-
Etes a:3
Enter:8
Ato soopp+n a =8.00
AHer onprn b 300
3) W-cite a proaam to ckoik ohe Rer a
iven yea leap yea ox owot
)ielse Stadem
Ars
E nude tRoh
Fa+ maC)

intyea
pidf( Enter a ye")
zcanf("zd",jea);
f(Yea 40o = = o

peilf("d a lear yes yeas

else it (yea loo = -


o)
pifEnte b ");
Ataf ("f, b)
a a-b
a+b

p f ("Afex Auooppia %.2f\»,«);


pintf("AH usaptb .2f", b);
Aetusn O;

Output
a)shg hiv Va«lable
number: 2
Eter at
Enter eond umber: 6

nunmbex 6.00
Atx &uwappig kAt
=

Ates 2 0 opT 2econd mwbeN 2 00

vaiable:
Eh ude tEo. h
wt nan ()

P+ yea
p&ttf(Ent a yao to ckeck f 7+ % a leap yes
O wot )
2 Cn
(4 xya<)
yea4-= 0 * yeax 1o0!= o) ?
riClrYeAx
yeax2 A00-:0) ? p(Lap Yes:ist

Outpu
Etes a yea -to ekek 1f H a leap yeax oY not

2020

Leap Yeax

4) Wite a progsam to ehexk whethex o 9iven


wmber APalholrome ev no
prat fC"2d note leap yeadyeax)
elef (e 4 = = o)

pstnt f(". 4u noa leap yea.yad);


1/

lse

prind d is no a
leap yeaN yeaY

Oudput
Etes a yea aoiS
2015 not a
leap yeas

Condet2onal Opesatod
Entade etato.1)

tn, Aeved Le=0, hemonder, oiginal


pntf(Eut o Teteqes: ");
pcamC%d', w)
oviginal = n j

whle (nL=o

hemander=n %lD
eNeLeA = heNa e 10+Yemainder ;

-10

otiqina== eNexies
sed)
pihf ("2 4 ia a Polindrome oniynal)
ele
prdf"7d nof a palindNome. origial
hetuxn 0
uet put
Entex an nteged 230y0d4o 2
3%04 O04022 is a Paltndrone
PaY-2 M

Wite a progsam to tnd e gvetet


wum pes amon the e e nub es
A Cay f-else atatemert:
in clude diok
intman)

Hoat nL, n2, n 3;


printf"Entoy three unbes : \n");
2Lan % f% f nLnM2,xns);
n i = n 2 x * n i = ns)

prndf,2{ ke lagest umbex.",n


else n2 >=ni na ns)
ww.bex., n2
else
pitf2.24ate lovqest uamber. ns
hetun 0
Dutpu-:
Entes hxee umbex&
38
T2

g5.00 a he aqst huneex.


Con&tonal Oportactoy -
Enelude 2tlio.h
itmain)

st a, b,C, Liy
pitf Eter thvee bex:\n);
a d Z4 Zd,"a, «b, ke
b a b ? (a>e ? a:c): (b>c? L:c);
ptf C 4te Liagest aybe :Zd", biq)
hetuxn O;
Output:3
Entex th ree U beN
24

A8
48.
The bigest muhmbe
Wsle a m e driven progrcam uw hiok has

oUwing opt
a Fautovial mumber
. n e or ot
C. Odd even
exft

inelude &tdo.h
nlude conio.h)
nulude proces. h
int main()

int K, hun f , ount =0,jimp


whele (1)

prt ckoose op4Eon.\nL Fatoval nanbey


n 2 ime eY notn3. Odd ox even
nA4. Ex \»")
Seanf "% d",K);
oit e C)

cae printf C"Entey umbox \")


Conf"2d", num)
N (int
tov i =1, ii= num : i++)

p@tf(Fautorlol of %d 24am f)
break
| Cae 2: pvatf°Etey numbey")
Can d ' , kmn)
lor (it =2 iL= num/2 ; i++)

Coun 4

Count =:0x num=


printf("% { a PYme hun Lex ", um

else
p r + f" 2 i ota prime unbey
en M

beak,
case 3 prêntf(Enter numbern")
.ean %.d", Km)
2 == o)
pretf ("2 ia wwwbex',um)
else
print f C% asodd ber, / uwn)Mm

bea
Case 4: pttf
(*Nthg to prit");
e+(1)

ptf\,Enter J to qo bak ka man Men o

n ElexO to nt')

(fmp1)
Conttnae

elke if - - o )

beaki

Yetuy O
Output
CLeoke optton
1.Fauoxal nunbey
Pfmeot
3 Odd x eren

4. Exf+F
1
Entey wumbex

ia 120
Fattoval o
E t e s 1 t o qo bask te nman M enu

Choo se optisnL
L. Feteytal numbey
2. e o% not
. Odd er even

4.E

Notieyto prfat.
DAY
O 8f a kve dht
-

put treugk te keyhoaxd


wHe a pogam to caluulate he gum of d l .

A
Enude 34olis.k
MaL ()

i t wum, a,b,c,d,e
Ktf(Eutex a Eve dtt www.bey:")

e wam % 10

/to)% to
C
Am /Loo) to
b ntoe)lo
a wn106co)
psft(%d a unotke dPBa of tte
num.bex d", atbte +dte,m)
Aetusn 0
Outpu
Etex a tive dalt wm bex 1 t 4 9

a6 Te he um of-te oltts of he uwnber 1549


etexed r o ug 4Re keyboor o
o o umberg ae

w t e a proram to no +Re value tone


han b e hai to pouex of anotkex.

An
include tdo.h
nlole toneo. h>
fnelude att.)
nt a i C)

vint Endex tke valwe of a


)
prftf (Ete Hhe volne bf b:");
Rtanf C*%d", )2

b9
hele (L!= o)
C a

hetuxn O

Outpu
Exter he value ot a :4
Ente ke value o,
4 holeto he powe 5 : 62S

m to prt all Kne wan. bex


te a

beween i t o LDo.

Aw
inude (atdo.hn)
iman ()

fwt, a= i , tout
plle (aL= tsu)

CoLuMt O
L2
wif le (tL=aj1)

(aCai= o)

Countt+
bsea.k

u t =0 xk al =1)

at++

hettrnO

Outrut
13 2 2
2
31
3' S7I13
3t 41413 47 S
1S9 61 6

3 19 69 F
DAY
M
OWtte a potam to proalue. tollowig output
ho DAiRs given bye)>
) A D

A
A

E indude (et ddo.h


ntade ondo.
n Man )

putf('Ete nambex o es \n)

fp Ca+ t-o; iin it+)

pxt 1-o; Ap<iiAp tt)


tf )
bor(rht j-o: {<a-ii jt+)
pefaf("2e', c)
C++

qt( " )

he urn0

Out pui
Ete um bey of {ine
A
A
A

2
S

hude (4tdfo«h
E inilude Ktono h
int waun
pvint"Entos umbey of ne n")

fint -0 iin i++)

pt f )
f t , t - (t» (C+09/2)+1; jki
t+t++)

hetuxn 0

Output 1

Enter wmber of ines


4
2
6
CC). E = A + 1/1l+ 1/1 t 1/+
Enlude Adeo.L
+nuude tonto. k>
tman)

Aouble =1:0
ptf"Ente wanber i texmt n")
pCanf{, x*);
l = 1 ; iin; èt+)

fatf1
eY C-t 1 jk=t;jtt)

+ 107f
t

p t ( Theseayeve
hetusn o
Owtput
E t e wun, Lex otteym
S
The heqered um 2to8 333

You might also like