217k views
0 votes
Write a program that will prompt a user for the size of an array and then create the array and using rand() populate the array with values and then print the array after the values have been populated in c

1 Answer

3 votes

Answer:

I'm assuming the array is of type float.

#include <stdio.h>

#include <stdlib.h>

int main(void)

{

int num;

printf("Enter the size of array: ");

scanf("%d", &num);

float arraydat[num];

for(int i = 0; i<num; i++)

{

arraydat[i] = scanf("%d", rand());

}

for(int i = 0; i<num; i++)

{

printf(" %d ", arraydat[i]);

}

return 0;

}

Step-by-step explanation:

User Ricardo Alves
by
5.3k points