0% found this document useful (0 votes)
3 views9 pages

Lekhana R

The document contains various C programming examples, including checking if a number is even or odd, finding the largest of three numbers, displaying the day of the week based on user input, calculating the sum of natural numbers, and reversing a string. Each example is accompanied by code snippets and expected outputs. The document serves as a practical guide for basic C programming concepts and syntax.

Uploaded by

Lekhana R
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 views9 pages

Lekhana R

The document contains various C programming examples, including checking if a number is even or odd, finding the largest of three numbers, displaying the day of the week based on user input, calculating the sum of natural numbers, and reversing a string. Each example is accompanied by code snippets and expected outputs. The document serves as a practical guide for basic C programming concepts and syntax.

Uploaded by

Lekhana R
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

eoqeaMMIN4

Assiçent- 02 -

NaMe :. Lekhana
CLASS :- BCA
BCA B'

Rou NO

USN ;" 5CA 25CA0061


Proqramm
númber S Eveen Orto ochecK [Link] a qiven
cdcd
#inclucle <sudio.h using -ESe.

int mainc)

int num

Printe (' eer a numer ")


Scanp (" d'',k nom

i Cnum 2=0)
Printf Cu is an even n",nom)j

Pintf C" y-d is an odd in, nom))


return

qut Put
Enter a number :+
+is odd
ASing nested
St atemen ts

#include<stdio .hy
int maioc)
int a bc;
Printf C enter three numbers:)',
Scanf Ce.d r.d y.d", e a, dob, C)
i (as b)
i# Casc)
Printf C" y. d is the targtst number.n"a
Else
PrinfC" % d is the taYqcst number g ;

Printf C -d is the laraest number n b1


EISe

PrntfC".d is the tarqest num ber.\n",dj

Output
Enter three numbers : 12 4 5 23
45 is the
\argest number.
wite a Cc proqram to displcy the day of the

Week CmondaySonday) based on number -3)


Entered by the using d switch-case
Statemen.

#include <stdio.h)
int main C)

int day;
PrintfC" enter anumber Ci-):j
Scont (" d",& day;
Suitchcday)
Case 1:
Printt("Monday in;
break

ease 2
pintf ( Tue sday n"
breah
Case 31

pintf c" wendensday in")


breakj
Case 4;
Pintc"hursday
breanj

printe ("Fridayin");

br ear;
Case 6
Printf(" Saturdayn")
loreak;
a for (Oo
natura I numbers using
#include <st dion >
int main c
jnt marKs
int I, Somi =0
4or Ci= 1; i < = O ; i t t §
SUm= SUm t i
3

Prin tf ( The Sur ot the first natcl number

retrno,

Output
The sum of the pirst natura) num ber is 55
NrIite aCC proqam
proqiam to display 4he mutipicanion
table of a number ueing
ueng do- while toop
tinclude < etdioh
int main () $
int i: 1
do s

I| increment berore continue


to avoid infinite loop
Co ntinue, | 5Kip multiples o 5

break I| Stop iS gre ater


than 40

Output
I 2 3 4 8 4 I| 12 13 l4 L6 + \8 \q 2 22 2 3
6
38 B9 41 42
24 2G 24 28 29 31 32 d6 3H 36 3{
1 2.
1 2. 3 3 2 |
4
*I 2, 3 4 3 2I

tincude <stcio.h>
nt main co
i n tn 5 I number of o us.

Por Ci s|;ic=n, itt)


nPrintíng ocding space)
sèaces

Print¢ Cu )
Priht nCreasinc nembers

print (" %d , ) ,
cecre a Sing 0umbers.

Print C* d", K),

pri t e n

teturn O;

3
write a C intiaig
program todeclare
nedimeno\onal
lpa ValueS arrau
of 5
and a

prom +he integers


mazinnum Element uS er anc
in t he Pina the
#inctuce array.
<etdio h>
int mnain co $
int arrls
nt i, max

Print¢ C* enter s irdagqers: \n;

max = arr o]

4or Ci=); i2 s ; itt)s


i4 carrfi Js mnar)
max aY r J)

print 4 C TLne mascimum element in the

array
retur o;
3
Out pct S6 20
integers
a6 48 I2
Enter s
array i6: 664.
The m axim Element the
Reac String tne

DiG pla the length of the an dreverse


tne str(ing
ing w'tnbut using in sring
handling function
#include <stdio. h>

int main cl
Char str (ooJ
int i, Lenqtn
/ Peac
stirg from user j
Pintf C° enter a string.")
getscstr);
eorCi =0; str CiJ = \0";it+) s
lengthrt;
Print {C n Original str ing /. s",str),
Print 4 C\n ne serinog .d".
length
Iengtn
Pint4 (\n
Length of the stringi hd", engw
pvime ce in Reversed strirg ");
printeC.c,strCiJ);

Print (u in');
out put
3 Enter a String , Helo w orno
ovigina! String :Helo word
bength ot tne Sting :41
Reversed sriaa :dl0w olle

You might also like