I have a question in my assignment to find standard deviation and it requires user input. The user input is to be stored in an array. This happens on runtime. But the requirement also states to define constexpr for declared size of array. How am I supposed to do this and what does it mean?
Asked
Active
Viewed 69 times
1
-
Is there an upper bound on the length of the user input? – asimes Nov 18 '19 at 04:17
-
@asimes there's no limit on number of inputs. The only limit is that the user input value should not be greater than 100. – Umer Saeed Nov 18 '19 at 04:20
-
`constexpr` is a constant expression. Generally speaking, things with values that can be determined at compile time can be constant expressions. Things that can only be known at run time (like user input) cannot be constant expressions. If there is no upper bound on the length of the user input then it is not clear how you could make any kind of assumptions about it at compile time – asimes Nov 18 '19 at 04:30
-
@asimes and what is meant by this sentence 'The program will not prompt the user for input. Instead, the program will read input from standard input (i.e., the keyboard)' – Umer Saeed Nov 18 '19 at 04:41
-
This question might help https://stackoverflow.com/questions/19019252/create-n-element-constexpr-array-in-c11/34465458 – Paul Nov 18 '19 at 05:13