/* Find the second smallest value in an array */
#include<stdio.h>
int main() {
int a[50], size, i, j=0, s, ss;
printf("Enter the size of the array: ");
scanf("%d", &size);
printf("Enter %d elements in to the array: ", size);
for(i=0; i<size; i++)
scanf("%d", &a[i]);
s = a[0];
ss = a[0];
for (i=0; i<size; i++) {
if (s > a[i]) {
ss = s;
s = a[i];
}
}
printf("Second smallest: %d", ss);
getch();
return 0;
}
Tuesday, February 10, 2015
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment