Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

C programming : How to write a program that is calculating age using function?

OpenStudy (anonymous):

/*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...:)

OpenStudy (anonymous):

do u mean, by using the date calculation, in term of this date is minus with your birth day?

OpenStudy (anonymous):

yea... using date

OpenStudy (anonymous):

owh i think you need to convert it to number then do the minus, and then convert it to year

OpenStudy (anonymous):

okay, i'll try it. thanks =)

OpenStudy (anonymous):

your welcome, but you need to aware with the number, use long integer instead integer

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!