> For the complete documentation index, see [llms.txt](https://www.introtoc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.introtoc.com/session-3/veggies.c.md).

# veggies.c

```c
#include <stdio.h>

int main() {
     // Menu
     printf("Menu\n");
     printf("1 - apple\n");
     printf("2 - banana\n");
     printf("3 - cherry\n");
     printf("4 - asparagus\n");
     printf("5 - broccoli\n");
     printf("6 - carrot\n");

     // get choice from user
     printf("Choice: ");
     int choice;
     scanf("%d", &choice);

     // rewrite code below using switch
     if (choice == 1) {
         printf("fruit\n");
         printf("sugary\n");
         printf("yummy\n");
     } else if (choice == 2) {
         printf("fruit\n");
         printf("sugary\n");
         printf("yummy\n");
     } else if (choice == 3) {
         printf("fruit\n");
         printf("sugary\n");
         printf("yummy\n");
     } else if (choice == 4) {
         printf("veggie\n");
         printf("healthy\n");
         printf("green\n");
     } else if (choice == 5) {
         printf("veggie\n");
         printf("healthy\n");
         printf("green\n");
    } else if (choice == 6) {
         printf("veggie\n");
         printf("healthy\n");
         printf("orange\n");
    } else {
         printf("Invalid\n");
    }
}
```
