C programming : How to write a program that is calculating age using function?
/*program to calculate the age*/ #include<stdio.h> #include<conio.h> int age(); void main() { int yr,a; printf("enter your year of birth\n"); scanf("%d",&yr); a=age(yr); printf("\nYour age is %d",a); } int age(int yr) { int x,y; printf("enter the current year"); scanf("%d",&x); y=x-yr; return (y); } i hope that it will help you...:)
do u mean, by using the date calculation, in term of this date is minus with your birth day?
yea... using date
owh i think you need to convert it to number then do the minus, and then convert it to year
okay, i'll try it. thanks =)
your welcome, but you need to aware with the number, use long integer instead integer
Join our real-time social learning platform and learn together with your friends!