IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
COne Dimensional Arrays ❯ Enumerated Types
<07.12>
/* Enumerated Type for Budget Expenses */ /* Program demonstrating the use of an enumerated type */ #include <stdio.h> enum expense {entertainment, rent, utilities, food, clothing, automobile, insurance, miscellaneous}; void print_expense (enum expense expense_kind) { switch (expense_kind) { case entertainment: printf("entertainment"); break; case rent: printf("rent"); break; case utilities: printf("utilities"); break; case food: printf("food"); break; case clothing: printf("clothing"); break; case automobile: printf("automobile"); break; case insurance: printf("insurance"); break; case miscellaneous: printf("miscellaneous"); break; default: printf("\n*** INVALID CODE ***\n"); } } int main(void) { enum expense expense_kind; printf("Enter an expense code between 0 and 7 > "); scanf("%d", &expense_kind); printf("Expense code represents "); print_expense(expense_kind); printf(".\n"); return (0); }
Hergestellt in Deutschland / Made in Germany
Enter an expense code between 0 and 7 > 5 Expense code represents automobile.
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.