array-1.c - C Program with an array. | Lecture 1 - slide 20 : 34 Program 1 |
#include <stdio.h> #include <stdlib.h> int main(void) { double a[] = {1.0, 2.0, 3.0, 4.0, 5.0}, sum = 0.0; int i; a[1] = 2.2; for (i = 0; i < 5; i++) sum += a[i]; printf("Sum = %f\n", sum); /* 15.2 */ return 0; }