C PROGRAMMING

write a c program to find smallest element of an array

C program to find smallest element of an array

 

  #include<stdio.h>
#include<conio.h>

void main()
{
int arr[10];
int size,small,loop;

printf("Enter the size of array n");
scanf("%d",&size);

for (loop=0; loop<size;loop++)
{
printf("Enter %dth element of arrayn",loop+1);
scanf("%d",&arr[loop]);
}

printf("Elements you have entered are :n");
for (loop=0; loop<size;loop++)
{
printf("%d ",arr[loop]);
}


small=arr[0];

for (loop=0; loop<size;loop++)
{
if(arr[loop]<small)
{
small = arr[loop];
}
}

printf("n Smallest element of array is %d",small);


getch();
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button