I have got a question. When a user enters a number, it will automatically be prepared to get that amount of variables.
Exp:
Enter numbers to process:3
Enter number:1.2
Enter number:17
Enter number:12
thanks.
This is a discussion on Enter a number within the C Programming forums, part of the General Programming Boards category; I have got a question. When a user enters a number, it will automatically be prepared to get that amount ...
I have got a question. When a user enters a number, it will automatically be prepared to get that amount of variables.
Exp:
Enter numbers to process:3
Enter number:1.2
Enter number:17
Enter number:12
thanks.
So you read a value into say n
Then do
for ( i = 0 ; i < n ; i++ )
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
You also have to allocate some memory for vars:Code:#include <stdlib.h> // Some crap int n, i; double *dTbl; scanf("%d", &n); dTbl = malloc(n*sizeof(*dTbl)); for (i = 0; i < n; i++) scanf("%f", dTbl[i]); // TODO: Do something with your numbers free(dTbl); // Remember to free allocated memory