Currently, I am asking user to specify number of input values being specified. This the code for it:
#include<stdio.h>
#include<math.h>
#include<string.h>
void main()
{
int i,n;
printf("\nHow many record you will enter: ");
scanf("%d",&n);
float x[n];
printf("\n\nEnter the values of velocity (m/s):");
for(i=0; i<n; i++)
{
scanf("%f",&x[i]);
printf("\n%f",x[i]);
}
}
The code runs fine. But, I want to write code in such a way that it will calculate 'n' by scanning the input (numbers separated by space, not necessary one space between each number) without asking the user. Can you suggest me a way for it.
PS: I am new to coding
Thanks in advance