Write a function that reads real (fractional) numbers, 𝑥1, 𝑥2, … , 𝑥𝑁 from the keyboard
into an array of N, starting from index 0. The numbers are read after a prompt.
#define NO_OF_DATA 500
main(void)
{
int n,l;
float InputData[NO_OF_DATA];
printf("\nEnter the no. of data to be entered: "); scanf("%d",&l);
for(n=0;n<l;n++)
{
printf("\nEnter Data No. %d : ",n+1); scanf("%f",&InputData[n]);
}
printf("\n\nEntered Data: ");
for(n=0;n<l;n++) printf("%.2f, ",InputData[n]);
return(0);
}
Comments
Leave a comment