+ 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; }
3 Respuestas
+ 1
Thanks😊
+ 2
Please specify a relevant language in the tags. e.g. C instead of 'ok' (which is irrelevant).
+ 1
To iterate the purchases array, i.e get every elements in the array one by one. Each element is added to total.