Created
April 23, 2022 19:08
-
-
Save sorin-ref/26ecbf05d476e22077622d8c3e4cd365 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
int main() | |
{ | |
time_t t = time(NULL); | |
struct tm tm = *localtime(&t); | |
int an_curent = tm.tm_year + 1900; | |
const int varsta_maxima = 125; | |
int anul_nasterii, varsta; | |
puts("In ce an te-ai nascut?"); | |
if (scanf("%d", &anul_nasterii) < 1) | |
{ | |
puts("Eroare."); | |
return 1; | |
} | |
if (anul_nasterii < an_curent - varsta_maxima || anul_nasterii > an_curent) | |
{ | |
puts("Eroare."); | |
return 2; | |
} | |
varsta = an_curent - anul_nasterii; | |
printf("Varsta ta este: %d\n", varsta); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment