Kodewick
Start learning →
Starter←→0 / 70

Level up

#057StarterStructs3 min

Little hero Pip beat a monster and levels up: level goes up by 1 and hp by 10. Change those two in hero; the line that prints them is already written.

Should show
Pip: level 5, hp 90
main.c
#include <stdio.h>

struct Hero {
    char name[20];
    int level;
    int hp;
};

int main(void) {
    struct Hero hero = {"Pip", 4, 80};
    // your code here: add 1 to hero.level and 10 to hero.hp
    printf("%s: level %d, hp %d\n", hero.name, hero.level, hero.hp);
    return 0;
}
Ctrl + Enter runs too
Result

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