0% found this document useful (0 votes)
37 views21 pages

04 - C Example Programs

Uploaded by

akofficial905
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)
37 views21 pages

04 - C Example Programs

Uploaded by

akofficial905
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/ 21

SP ENGINEERING ACADEMY

Video Lectures / Course Materials

COMPLETE COURSE
PROGRAMMING IN C LANGUAGE
Part – 04 – C Example Programs

Topic # Content Page No.


Program to Display Single Dimensional Array - C Programming Language -
01 02
https://youtu.be/dF_kQwUWnUs

Program to Display Two Dimensional Array - C Programming Language -


02 03
https://youtu.be/nt9V7G7RsEo

Program to Perform Matrix Addition - C Programming Language -


03 04
https://youtu.be/JJo3NACrk_s

Program to Perform Matrix Subtraction - C Programming Language -


04 07
https://youtu.be/ud8KGeb_U6w

Program to Perform Matrix Multiplication - C Programming Language -


05 10
https://youtu.be/Hv50uSRkEXY

Program to Arrange the Number in Ascending Order - C Programming


06 13
Language - https://youtu.be/PYdeYzbm6IY

Program to Arrange the Number in Descending Order - C Programming


07 15
Language - https://youtu.be/doBfslY7tOQ

Program to Search the Number in the Given Array - C Programming Language -


08 https://youtu.be/kwyBYDGhYgY
17

Program to Find Maximum Number in the Given Array - C Programming


09 18
Language - https://youtu.be/jCRXfQf3pxE

Program to Create Student Database using Structure - C Programming


10 20
Language - https://youtu.be/MNKq2Z79V2s
Video Link - https://youtu.be/dF_kQwUWnUs

Paogman to Dieplay Singl Dimensionl Ag


ats] : f , b, io, Jeo, 83;
alo] al11 al2] al3 al4]
Ay
Amay
Eleme
Tadiuso
lo loo
3
8

include<stdio.h>
#include Lconio.h>
Void main)

int aCiool, i,n


clrsex;
Pint ("Entey Number Aa ElemenliL
Stan (" .d",
Pintf' Frtex Ay Elenentia );

Scanf ('dari);
Printf (The Arsey Elemenk are \n)
forlizo; ien;)
Bintpc".dini, ace):
3

Output.
Enter Nun be af Any ElemenlalThe Azay Elesenk ane
5 21
Ertex Aray Elemeli
2!
Video Link - https://youtu.be/nt9V7G7RsEo

Program to Displey Tao Dimen sinl Aray


aL3]L3]=|3, s, 4,8,9, 3,2,14
Climn o Cen Clumn 2
3aleJlo] S alely I aloJ[2]
Rouy 1 4 ali]Ce] 8 al1 9aCJC2]
Rouw 2 3 ac2][J 2 ac1c] alJc2]
Column Index
Row Index
Array Name.
Atray Elemenk
#include <Stdio.h
# include <conio.h
Void mainc)

int aliolLol m,n,ij


clrser}
BintfEntey Number oB Rows and Gtumasln);
Scanp l" Zd Y.d'Am, n);
Pint (" Enter the elomeni p Matian);
Bor (e=oj C<m; t)

Scanp (".d"alJCi);

Pon( The Gien Maton is ln

Pintf("d\t acici);
3
Pintf'\n
Outpuk
Enter Numbex R Rous and Ctumns
33
Entex Re Element Metia
35 44 8 9 3 27
The Given Matiz is
3 S
4 8
2 7
Video Link - https://youtu.be/JJo3NACrk_s

Pogram to Perfarm Mettia Addition


Dimensiam isk Matin
Dimensisn o Second Maton m2
Conditin Bor Matâ, Addihn m= m2 and niz n2
Resultoant Mati Dimensin oY n2 X n2

3 67
Matin Tnder,
2 4 o 2
A 2 4 B b 7 |2.
2 | 4 20 24 22

3+| 6t2 1+4 4_8 L


2+6 4+9 3
S3 2+4
#include < stdio.h
tt incude <Conio.h
Veid main) 1g
aye
-tru
ler

int aco]Cio], bLe]Ciol, cCio][io] mi, m2, nl,n2,-ydj "st


de

Pint ("Enter tRe Nurmbér d Rous and Gln Bid Mtinsa)


Scanß".ddm, An), a

Prik"EndertRe Number e Rous and Glms Semd Matia I

Scan (" d 7.dm2, n2);

Pint (" Etey tRe eenenk it matinl);


orlaoj

Printe"Ente, tRe elemenli f Secend mahian);


torlizo; <m

Borl/zoj j<n2j4tt)
Scang("d blJLi;
Borl Czo i<m1 ++)

Print ("The senltan Additien Matòn uln

Bocljo,nnyJtt)

elae
Print Mat Additin i net Pocsibe:

Output 1
Enter Num ber o Rou and Cunns kisk matóx
33 3
Enter Number o Row and Guns Second matin
3 3
Ente, Re elemendi Bil Matäa
36 2
2 L 4 s 82
Entex tRe elemeni Secmd MatiA
2 4 6 J9 3 4
The Re&ultant Addition Maton e
4
3
8
Output 2
Enter Num ber f Rous and Clumns inse Matin
3
Entes umber o Rous and Clunns Secod Main
2 2
Aatin Addii à not possi bte
Progam to Penßon Matrin Subction
Video Link - https://youtu.be/ud8KGeb_U6w
Dimension Rizt mathx
Dimensia Second matia
Condition Bur matin Subtectim m= m2 and ni n2
Resultant Matin Dimensin
bLoJCOJ
88 6 9 4

7S 4 B S4 2

| s 33 l21o1 21[] [21[21


icCoJCo]
8-6 6- 4 q-8 2 2
7-5
S-4 4-2 2 2
b-s 9-3 S-|
4

CCoJ[oJ_ = alo[]

b[2]C2]
aleri] - b[eICII
#inclucdo < Stdio
#înclude <lonio.R
Void mainc)

int alio]e1, bDiel[iol,c ie]Liol, mi,ni, mz,n2, dj


clrser;
Pint " EntertRe Number s Rows and Gins Bit mti
Stanß ("d Yd" m, n)
Psint ("ntex tRe Numbér Rous and Cunn oe Second Mati;

Scanp ("y.d,laciscij);

Psine("fnte, tRe elbment e Secend Matin);

Scanp(" yd' bliJci);


Page

Bor ll=o; <mi tt)

cceJCiJ = aliJci] - blJcil;

Pän The Resltonl Subhaction Matia ul ;


Borll=o (<m; (+#)
Borlj=onjdt+)

elee
Pint( Matia Subhection à not Possi be")

getRco;

Output 1
Enter e number f Rouss and Glunns pist matax
33
er
EntesRe number f Roue and Clmos Secnd matix
33
Entey tRe elemento Bist matix
&6 9 7 S 4 4. 6 S
Enter tRe elemenh Second matix
648 44 2 S 3
The Resultant Subtacti Matin
2 2 1
2 2
4

Enter tRe number Rows and Cotma Bist matin


33
Enter tRe number Rous and Clean secod matia
2 2
Matix Subta tin u noc Posibe
Progren to Video
Perßorn Matrix Mulipliation
Link - https://youtu.be/Hv50uSRkEXY
Dimensi¡n d Dimeosin P
fixt Mati Second Mati

Condition
n=P

Resultant MatH mX
Exampe
2 X3 X2
2 4 |3 S
A =6 3 S
2

|X3+ 2 Xb + 40 IXSt 2x7 + 4x2


C
6X3 + 3X6 tS X) 6XS 3*7 t SX2

3 t I2 t 4 27

3o + 2) +)o 41
c[iJL0J= cCJCiJ+ aliI[K] x b[Kci] 2X2
Second Matin Px
Resultanle Matia
Gndition
#include < stdio.Rz
#inlude <lonio.R
Veid mnàn )

int aLioJLuoI, bLieJLicl, cLio][ie, m, n, P,4,kj


clrscy
Rousk and Glumn t Mehin;

Prin ("Eter tRe Nuvmber ae Rous and Glmn o Secod Matin";

Panp("Enter Re Elemenli fint Matix";


Bor lizo kn, (+4)

Scang (" d", ariiri);

Print ("Enter tRe Elemes s Secnd Matin")


Bo (C20; (<p; t+)

Stan ("ydblicjJ}
ay
tr
le

Bor k=o kkn, k++)


cLJLIJcccTt alJCK] * b[KILil;

Pintc"he Reltent Muliiatin Mati \n;


fallzo; <m, t+)

Printf(td"n)
3

ele
Output1 ati
Rows and au Ask
Enter tRe Number et
2 3
Enter tRe Numbey RowS and Cimni e Second Matix
32
Enter Ae Elementa o frsk Mati
24 6 3S
Enter tRe Elenenli o Secmd Matix
3 S 2

The Resultant Multiicatin Matix


|921 41

Dutput 2 Second Matin


Enter Re Numbey o Ros and Clemns
3 3
Entey Re Number o Rouws and Ctumos Second Matix
2 2

Matin Mulhptiation is nole passibte


Arrange
Pogram oVideo Re NumbeYA in Ascen ding Order
Link - https://youtu.be/PYdeYzbm6IY
Gonside fve Numbes
Ascanding Order
Ordes - Minimun to Mammum

Gomparison witR fint NlumberGmpansn witk Secand Numbex


3
8 3
3 8 69 S
3S 96
33 86 9S
Comparsn witÆ Rid number Compascn wik ontR Aunber
3 3

3 3s689
- A
scending Orde
#includ <Coni.
Veid ain ()

int aLieo], n, itempj

Scanp (" Yd' h)


Prini ("ntey +Re Arsay Eleenli";
orl(20 (<n (++)
SCanf (".d"ar);
3

s(alil< alil
temp = aCil;
arij = acj];
aLjJ :tempj
3

Prin (" Ascanding Order is In);

3
Pintfc"sdl ali);
Dutput
Enter Total Number d Elemena
5
Entor
836
tRe Armag Elemena

Ascanding Order ia
3S6
Video Link - https://youtu.be/doBfslY7tOQ

Pgam to Arenge Re Numbezs in Deending Ordat


CGnsidex Ave Nuabes 8 33_69S
8
Desending Oxder - Madimum to Mini
Compaisn wiR As- NumberCamporisn wiA Second Nmbe
3
a 36

3
9 8 3 6 5
368S

Comparison witR Thd Number CampaHsen iR outt Number

9 8 q86S 3
b 3 S Desending Dxdes
#inelude <stdio. R
# include < Gonio. h
Void main ()

int al1ool n, d tempj


clserc)}
Print (" Eoter Number oß lemena";

Pint (" Enter the Atray Elemenla ");

Scanf ("Ldace)

JP(ariJ<aci)
temp : arij;
ali]: alili
aLil z temp
3

Prntf (" Deending Onder iun

Output
Enter Number Elemena
5
Enter tfe Arya Elemenlt
3 9
Desending Order is
q S 3
Pogram to Searel an Elemenk in Arrray
#include<stdio. R
g
ay

Void main) t
ler

int alhecl, b,iearel, Bouned n


d

clrserc
Pint(Ertey Total Number o Elemena ";

Pön (Etea Aray Eleneaka" );

Scanß(" d' lalii);


Print (Entee tRe elementto seave");
Scan (" yd'&eareh);
Round =oj
(++)

Ul al] == Seare)

foaund
break

else
Bound in tRe aragsaneh),
gelelo
Page

Output 1
Enter Total Number Elemea
lo
Enter Aray Aemenlk
2| 12 2203o3o 4|
4 66 &8 126
26S lo0
Enter tBe Element to Seave
30
3o u ound at positian 4
Output 2
Enter To-tel Numbe Elemeni
Enter Aya Elemenla
21 12 20 3o 4 b 8 25
Entey Re Eement to Seare

so u nd found in tRe Aray


Video Link - https://youtu.be/jCRXfQf3pxE
Paugran to Pind Maximum Elemenk in Array
#include < Conio. R>
Void main)

ink aLioo, n,, man

Print ("Emtor tRe Numter of elamat in Ats";


Arm
Print (" Erter tRe Atsay Elemeaa")

3
ma=
aLolj
C++)
iaciJ_ max)
max = ali]
3
Pintp("The Mazimun Elemeat in Re arm is Zd,mo

Outpuk
Enter Re Numbe lenenh in Aray
5
Enter23tRe 18Array 48Elemela
56
The Marimn Element in Re A
Video Link - https://youtu.be/MNKq2Z79V2s

Progra to Store Studext Inßormaion Usina Sthucuve


jnlude < stdio.. Ry
# ioclude < stdi Conio
Struct Stucdent

har Damelool
int
int matRs;
ink phy
ink cke
int totl
Ploct avg
Veid main()

int & int nj


clrser;
Pönt (nter Totol Number Students")
Scan CY.d', n);
Pinte C Enter Student Details")

Print Erter Name he Studert;


Seant same j};
Scanf ( ys sce], name);
Pint (" Erter Regis ter number");
Scan (" d s c ] . egno),
PöntEatey make in Matk's, PhysiA and clemish
Scan(".d z.d "AsiJ mat®, SLJ phy, st<.cke)y
SCJ. total = s[i]. matBs+ sr. phy + sr].cke
Point " The stacdont Detaila ae\n);

Ponte (" Name:.sh, stiJ. nome);


Psinte (" Regis te Numbes
Prinf MasRematis i d, siiJma tRs)
Pin (" Physius i .dln'y srij phy
Prin c To tel mate .din", sre total;

Outpuk
Enter Total numer o Studeaa The Stdent Detls are.

Enter studen Details Name


Entey lame of tRe Studenl Roja
Kegister Number i 2023S010
Raja Mathena tics : 98
Enter Kegicter Number Physis : b
2023Solo
Erter Metk in Matß, Physiu and Caisty
clemistey:47
Totl Ma : 241
9697 Average 97
Enter Name te Student Name ; Aun
Arn Register Number: 2023 SooS
Enter Kegister Number MatRenatica i loo
2o23SooS
Phytia
Enter Meakin MattPoysis and cRosa Cenistry 99
Total Mak:297
Averge :49

You might also like