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

Exp 8

Uploaded by

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

Exp 8

Uploaded by

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

UG Program in Electronics and Communication

(Advanced Communication Technology)

Experiment No. –8
Date of Performance:
Date of Submission:

Program Execution/
formation/ Timely
Viva Experiment Sign with
correction/ Submission
(03) Total (10) Date
ethical practices (01)
(06)

Experiment No. 8
Study of one-dimensional Array.

1.1 Aim: Study of one-dimensional Array

Problem Statement: Write a program to find largest and second largest element
of array.
Problem Definition:
Input: Accept elements of an array.
Processing: Sort elements of an array in ascending order.
Output: Display largest and second largest element of sorted array

1.2 Course Outcome: CO 4

1.3 Learning Objectives: Implement one dimensional array


1.4 Requirement: Computer, Suitable IDE

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-1


UG Program in Electronics and Communication
(Advanced Communication Technology)

1.5 Related theory :


AnarrayinCProgrammingLanguagecanbedefinedasnumberofmemorylocations, each
of which can store the same data type and which can be referencesthrough the same
variable name. An array is a collection of similar elements. Thesesimilar elements
could be all integers or all floats or all characters etc. All elements ofany given array
must be of the same type i.e. we can’t have an array of 10 numbers, ofwhich5
areintegers and 5arefloats.

DeclarationofanArray:
Datatypevariable
name[lengthofarray];forexample,
double
height[10];float
width[20];intmin
[9];
charname[20];
InitializingArrays
Initializing of array is very simple in c programming. The initializing
valuesare enclosed within the curly braces in the declaration and placed following an
equalsignafterthearrayname.Hereisanexamplewhichdeclaresandinitializesanarrayoffi
veelements oftypeint. Arraycanalso beinitialized afterdeclaration.

int myArray[5] = {1, 2, 3, 4, 5}; //declare and initialize the array in one
statementintstudentAge[4];
studentAge[0]=1
4;studentAge[1]
=13;studentAge[
2]=15;studentAg

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-2


UG Program in Electronics and Communication
(Advanced Communication Technology)

e[3]=16;

Algorithm:
Step 1:Start
Step2:Declarevariablesand array(i,j,n,x[20],temp)
Step 3:Readthevalueoftotal no.ofelements i.e.ninarray
Step4:Initializei=0,repeatstepno.5untili<totalno.ofelements
Step5:Readtheelementsofarray.
Step6:Initializei=0,Repeatthestepno.7untili<n-1Step7:
Initializej=0,Repeatthestepno.8,9,10untilj<n-1Step
8:temp=x[j]
Step 9:x[j]=x[j+1]
Step 10:x[j+1]=temp
Step 11:Displaythelargestandsecond largestelement
Step 12:Stop

Flow chart

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-3


UG Program in Electronics and Communication
(Advanced Communication Technology)

Program and Output

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-4


UG Program in Electronics and Communication
(Advanced Communication Technology)

1.6 Conclusion:
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
………………………………

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-5


UG Program in Electronics and Communication
(Advanced Communication Technology)

1.7 Questions:

Write advantages of array

……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
…………

Skill Based Lab: C Programming (ACLOR0VS101) A.Y. 2024-25 8-6

You might also like