WAP in C to Find Smallest Element in an Array?

#include<stdio.h>
#include<conio.h>
int main()
{
int a[30],i,num,smallest;
clrscr();
printf(“\nEnter size of array:”);
scanf(“%d”, &num);
printf(“\nEnter the elements of array:”);
//Read n elements in an array
for (i = 0; i < num; i++)
scanf(“%d”, &a[i]);
//Consider first element as smallest
smallest = a[0];
for (i = 0; i < num; i++)
{
if (a[i] < smallest)
{
smallest = a[i];
}
}
// Print out the Result
printf(“\nSmallest Element : %d”, smallest);
getch();
return(0);
}

Output :-

smallarr

Advertisements

2 thoughts on “WAP in C to Find Smallest Element in an Array?

  1. I am now not sure where you’re getting your info, however good topic. I must spend a while finding out much more or working out more. Thanks for fantastic info I was on the lookout for this info for my mission.

    Like

  2. You actually make it seem really easy together with your presentation but I in finding this matter to be actually something which I believe I would never understand. It kind of feels too complex and extremely extensive for me. I’m having a look forward for your next post, I will try to get the grasp of it!

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s