This program is taking an array of floats (A) & build out of it arrary of numbers (B) which are the priorities of the array A.

which means:

A={0.3;0.6;0.5;0.1}

B={3,1,2,4,}

what I get is only the biggest no. what is wrong with it?

Cheers!

Ronen

#include<stdio.h>

#define M 20

void func(float A[M],int n,int B[M]);

int i,j,n,max;

float A[M];

int B[M];

void main()

{

puts ("enter the size of array A from 1 to 20");

scanf ("%d", &n);

if (n>20||n<1)

puts ("number should be between 1 & 20. ");

else

{

printf ("\nenter %d positive numbers smaller than 1 for array A\n", n);

for (i=0;i<n;i++)

{

scanf ("%f", &A[i]);

if (A[i]>1||A[i]<0)

{

printf("number does not fit!");

i--;

}

}

func(A,n,B);

}

printf ("B=");

for (j=0;j<n;j++)

{

printf ("%d, ", B[j]);

}

printf ("\n");

}

void func(float A[M],int n,int B[M])

{

int i,j;

float max=A[0];

for(i=1,j=0; i<=n; j++,i++)

if(A[i]>max)

{

max=A[i];

B[j]=i;

}

}