Hello I wrote this program to generate 10 random numbers and put it in a array with 10 elements. But I want the results to be put into i decimal places. like 1.3 or 0.7 ect.... But instead it's like 1.0 and 0.0 can some one please fix my code for me or help me in any other way.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define size 10
int main()
{
int i;
float x[size];
/* Randomise the random number generator */
srand((unsigned)time(NULL));
/* Assign random values to the variable */
for (i=0; i<10; i++)
x[i] = (rand()%26)/14;
/* Display the contents of the array */
for (i=0; i<10; i++)
printf("element %d has the value %1.1f\n", i, x[i]);
return 0;
}