Witam, zacząłem naukę programowania w C i mam pewien problem. Oto mój kod:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char name[20];
char city[20];
int year;
int birth;
int age;
age = year - birth;
printf("What is your name?\n");
scanf("%s", name);
printf("Where are you from?\n");
scanf("%s", city);
printf("What year is it now?\n");
scanf("%d", &year);
printf("What year were you born?\n");
scanf("%d", &birth);
printf("%s is from %s and he is %d years old\n", name, city, age);
return 0;
}
Problem jest następujący, w ostatecznej fazie programu pokazuje on złą liczbę, np jeśli wpisałem że obecny rok to 2016 a urodziłem się w 1997, to pokazuje 1944375940 zamiast 19. Co robię źle?