Kodewick
Start learning →
Basic←→0 / 70

How many items

#032BasicArrays3 min

The grocery price list keeps getting new things, and you don't want to count them by hand. Use sizeof to work out how many numbers are in prices and put it in n; the next line shows 6 items.

Should show
6 items
main.c
#include <stdio.h>

int main(void) {
    int prices[] = {3, 12, 8, 5, 20, 7};
    int n = 0;
    // your code here: work out how many prices there are with sizeof, into n
    printf("%d items\n", n);
    return 0;
}
Ctrl + Enter runs too
Result

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