← Your First C Program

Declare and Print

easy

Declare a variable named age, of type int, set to 30 – then print exactly:

Age: 30

Two new pieces here, both of which you’ll use constantly from now on. First, int age = 30; – in C you always state a variable’s type when you declare it (int for a whole number), unlike Python or JavaScript where you just assign a value and the type is inferred. Second, printf("Age: %d\n", age); – the %d inside the string is a placeholder for an int value, filled in by the extra argument (age) after the comma. You’ll see this placeholder pattern (a different letter for each type) constantly starting in the next lesson.

Your solution

"Run" uses the sample stdin (none). "Submit" checks your code against all 1 test case.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution