question given
Finding the Smallest Value (small.c)
(a) Write a function, smallest( ), that returns the smallest value in a signed integer
array. The array and its size are passed as arguments.
(b) Write a main program that inputs MAX values from the keyboard into a signed
integer array, array, and prints, using smallest( ), the smallest value to the screen
hi all...
i really new for function especially those passing argument...
as the code written below, workable but seens like different from the question'requirement....
i did read book, but not really clear..therefore post and ask for guidance...
question mentioned a lot of array+ & argument.
FOr the written code below, can my smallest() function considered as passing argument? cause i return k..
for array if passing argument sure related to pointer?
thanks ...
Code:
/*Small.c*/
#include<stdio.h>
smallest();
int n,i,y,h;
int max[60];
main()
{
for(i=0;i<4;i++)
{
printf("Please enter number:");
scanf("%d", &max[i]);
/*printf("%d", max[i]); test for input */
}
h=smallest();
printf("minimum no is %d",h);
getch();
}
smallest()
{
int j,k;
for(j=0;j<4;j++)
{
k=((k>max[j])?max[j]:k);
/*conditioner operator:If y>max[i],=max[i], else=y */
printf("%d\n",k);
}
printf("%d",k);
return k ;
}