[go: up one dir, main page]

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

Array Programs

The document contains three C programs that demonstrate basic array operations. The first program reverses the elements of an array, the second finds the largest element, and the third finds the smallest element in an array. Each program includes user input and outputs the results accordingly.

Uploaded by

ksai.mb
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)
4 views9 pages

Array Programs

The document contains three C programs that demonstrate basic array operations. The first program reverses the elements of an array, the second finds the largest element, and the third finds the smallest element in an array. Each program includes user input and outputs the results accordingly.

Uploaded by

ksai.mb
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/ 9

1

2
3
#include <stdio.h>

int main() {
int a[5];
int i ;
printf("enter the elements of the array\n");
for(i=0;i<5; i++)
{
scanf("%d",&a[i]);
}
printf("elements of the array are \n");
for(i=4;i>=0;i--)
{
printf("%d ",a[i]);
}
return 0;
}
Output
enter the elements of the array
12345
elements of the array are
54321

4
5
6
7
Write a program to find the biggest element in an array

#include <stdio.h>

int main() {
int a[5];
int i,big ;
printf("enter the elements of the array\n");
for(i=0;i<5; i++)
{
scanf("%d",&a[i]);
}
big = a[0];
for(i=1;i<=4;i++)
{
if(a[i]>big)
big =a[i];
}

printf("biggest element in the array =%d",big);


return 0;
}

8
Output
enter the elements of the array
13425
biggest element in the array =5

Write a program to find the smallest element in an array


#include <stdio.h>

int main() {
int a[5];
int i,small ;
printf("enter the elements of the array\n");
for(i=0;i<5; i++)
{
scanf("%d",&a[i]);
}
small = a[0];
for(i=1;i<=4;i++)
{
if(a[i]<small)
small =a[i];
}

printf("smallest element in the array =%d",small);


return 0;
}
Output
enter the elements of the array
8 7 6 5 -2
smallest element in the array =-2

You might also like