Declare an array to hold expenses, and a counter variable - C Array

C examples for Array:Array Value

Description

Declare an array to hold expenses, and a counter variable

Demo Code

#include <stdio.h>

int main( void )
{
    float expenses[13];
    //from w  w w .  j a va2s .co m
    int count;
    
    for (count = 1; count < 13; count++){
        printf("Enter expenses for month %d: ", count);
        scanf("%f", &expenses[count]);
    }

    for (count = 1; count < 13; count++){
        printf("Month %d = $%.2f\n", count, expenses[count]);
    }
    return 0;
}

Result


Related Tutorials