when declaring variables in the main() procedure, is because you intend to use them throughout the whole program, though you can't use them in a function (unless you pass them as parameters by reference, not by value); when you declare them in a function, these variables are only useful as long as the function is running (meaning, they "die" at the end of the function); and if you declare the variables outside of any function or main() , they are Global variables, which can be used throughout all the program (meaning, main or functions).
and yes, you can get user input whereever you want to. depends on how you plan to use it what the most sensible location for it. if this is confusing to you, then just stick it in main() until you learn more about how subroutines work.
When you have a function and need to scan for 2 different numbers, should the scanf be in the function or in the main() and why?
No, you should not put the input in the function. The function's purpose is to do calculations, so keep it simple. Maybe another function for input. But keep the different processes (input, calculation, output) separate. The more you do in the function, the harder it is to debug.
I'm trying to use the numbers to do calculations in my function. I want user input to get those 2 numbers.
Then you want the input before you call the calculate function.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.