Created
March 25, 2015 04:00
-
-
Save tkovs/c3ae7274017625176f00 to your computer and use it in GitHub Desktop.
Calcula idade e depois realiza um paranauê.
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> | |
#include <windows.h> | |
int main(void) | |
{ | |
SYSTEMTIME str_t; | |
// n = nascimento | a = atual | |
int nDia, nMes, nAno; | |
int aDia, aMes, aAno; | |
int idade = 0; | |
GetSystemTime(&str_t); | |
aAno = str_t.wYear; | |
aMes = str_t.wMonth; | |
aDia = str_t.wDay; | |
printf ("Informe sua data de nascimento (dd mm aa): "); | |
scanf ("%d %d %d", &nDia, &nMes, &nAno); | |
idade = aAno - nAno; | |
if (aMes < nMes) | |
idade--; | |
else if (aDia < nDia) | |
idade--; | |
printf ("Idade: %d", idade); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment