Skip to the task
Layout
Back to classic view

You are looking ahead. Your place is still task 1: Types.

RUNTask 5 of 23 · step 3: The student cardRun p02_card
Run p02_card in practice/02/

File → Reload CMake Project, pick p02_card and ▶. Then change birth_year to your own year and run it again.

Checklist

  • Every task is one commit with a clear message.

Numbered notes in the code explain the important lines.

Details & hint
$ .\build\debug\practice\02\p02_card.exe
Year of study: 1
Group: PI25A
Age: 19 years
Average: 8.75
In memory: int 4 B, double 8 B, char 1 B

You should see: Five lines. The average with two digits after the dot, and int, double and char take 4, 8 and 1 bytes.

practice 02 main.c Code Diff +20
A · NEW FILE git diff: every line is new (+20).
--- /dev/null
+++ b/practice/02/main.c
@@ -0,0 +1,20 @@
+ #include <stdio.h>
+
+ int main(void) {
+ const int current_year = 2026;
+ int study_year = 1;
+ char group = 'A';
+
+ int birth_year = 2007;
+ double average = 8.75;
+
+ int age = current_year - birth_year;
+
+ printf("Year of study: %d\n", study_year);
+ printf("Group: PI25%c\n", group);
+ printf("Age: %d years\n", age);
+ printf("Average: %.2f\n", average);
+ printf("In memory: int %zu B, double %zu B, char %zu B\n", sizeof study_year, sizeof average,
+ sizeof group);
+ return 0;
+ }
opened for this task
$ .\build\debug\practice\02\p02_card.exe
Year of study: 1
Group: PI25A
Age: 19 years
Average: 8.75
In memory: int 4 B, double 8 B, char 1 B