4 Réponses
0
Find examples and explanations here: https://www.geeksforgeeks.org/format-specifiers-in-c/ Exactly, when we say passing array to the function, we mean that we pass pointer to its first element
20th Oct 2018, 6:34 AM
microBIG
microBIG - avatar
+ 7
Answer to Q1: %4.2f means you are printing floating point number upto two decimal places right justified by 4. Number before decimal (4) is to justify output either to right or to left. Positive numbers will justify output to right and negative numbers will justify output to left. Number after decimal (2) means that you want answer to be two decimal number. It simply means number of digits after decimal. Answer to Q2: Couldn't understand well what you are trying to ask, but there in the printf statement you are calling a function passing it the array and its size.
19th Oct 2018, 9:18 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
1) %4.2f - It is format specifier for float values, which means that float value will contain 4 symbols (minimum) in it and 2 of them will be for decimal part (after point symbol). 2) You pass 'orders' array to the function. No matter what is the name of your array, when you pass it to add_up() it will have name 'a' inside the function. It makes your code more flexible. Functions have their own variables which will be lost when function will be completed.
19th Oct 2018, 9:28 PM
microBIG
microBIG - avatar
0
thank you...microBIG I understand from your answer (of the second question)that the array wasn't defined to the function so we identified it by a pointer ... and can you explain the first answer with some examples
19th Oct 2018, 9:53 PM
Øùşsaɱa Gahaɱ Jr.
Øùşsaɱa Gahaɱ Jr. - avatar