Kodewick
Start learning →
Starter←→0 / 70

Pet card

#056StarterStructs2 min

The pet shop makes a card for each pet; struct Pet keeps the name and the age together. Use printf to show Mochi is 3, taking both the name and the age from pet.

Should show
Mochi is 3
main.c
#include <stdio.h>

struct Pet {
    char name[20];
    int age;
};

int main(void) {
    struct Pet pet = {"Mochi", 3};
    // your code here: print with pet.name and pet.age
    return 0;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.