+ 1

What is the need of for loop here..? (Bolowed program)

#include <stdio.h> int main() { float purchases[3] = {10.99, 14.25, 90.50}; float total = 0; int k; /* total the purchases */ for (k = 0; k < 3; k++) { total += purchases[k]; } printf("Purchases total is %6.2f\n", total); /* Output: Purchases total is 115.74 */ return 0; }

5th Sep 2020, 1:25 PM
Aashutøsh
Aashutøsh - avatar
3 Answers
+ 1
Thanks😊
5th Sep 2020, 1:31 PM
Aashutøsh
Aashutøsh - avatar
+ 2
Please specify a relevant language in the tags. e.g. C instead of 'ok' (which is irrelevant).
5th Sep 2020, 2:06 PM
Ipang
+ 1
To iterate the purchases array, i.e get every elements in the array one by one. Each element is added to total.
5th Sep 2020, 1:30 PM
你知道規則,我也是
你知道規則,我也是 - avatar