-
Whats wrong with this?
im writing this stupid program but somthing is wrong and i cant find what it is,no matter which ten numbers i input the output is always 0,can any body tell me why and how to fix it,thanks
#include <stdio.h>
main()
{
float v[10];
int i,imin,imax;
for (i=0;i<=9;i++) scanf("%f",&v[i]);
imin=0;
for (i=0;i<=9;i++)
{
if (v[i]<v[imin]) imin=i;
}
printf ("\n%d\n",v[imin]);
}
-
You use the %d specifier when you call printf instead of %f.
-
maybe because:
Code:
float v[10];
/* ... */
printf ("\n%d\n",v[imin]);
Also use code tags and main returns an int
-
Also, it's usually a safe thing but you can't always depend on your compiler to initialize a varaible to 0. It doesnt look like a problem here but is something good to know.