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