help with strings and int array's

create a program that accepts input of the following expenses:
food, gas, entertainment, medical, personal, misc
store this in an array
and ouput each item when complete with total expenses

use the following: if/else, string (strcmp), int arrays, error handling
i am not sure as how to start this program. please point me in the right direction

 #include <stdio.h>
#include <string.h>
#define SIZE 6

int main (void)

i pretty much want to enter variable in the settings like
gas = anyvariable
food = any variable

this all has to do with how much each thing cost for a week im sorry if i was not clear
Last edited on
#include <stdio.h>
#include <string.h>

float getTotal (float expense[6]);

int main (void)

char *Items[] = {"\nFood", "\nGas", "\nEntertainment", "\nMedical", "\nMisc" };
float expenses[] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00};
char askthem[] = {"Please enter the appropriate values for each item"};
char tellthem[] = {"here is what you put"};
char *erorfound = {"You have entered a value that is inappropriate"};
char *totalexpenses = {"Total Expenses: "};
float total;

printf("%s", askthem);
for (int i = 0; i < 6; ++i)
printf("%s : ", Items[i]);
scanf("%f", &expenses[i]);

printf("%s", tellthem);

for (int p = 0; p < 6; ++p)
printf("%s : %.2f", Items[p], expenses[p]);
printf("\n%s%.2f\n", totalexpenses, total = getTotal(expenses));

float getTotal (float Expense[6])

float total = 0.00;
for (int i = 0; i < 6; ++i);
total = total + Expense[i];

return total;

this is what i got but im still having trouble with the error handling
Topic archived. No new replies allowed.