Write a c program that will ask you to enter the year your were born and return your current age | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Write a c program that will ask you to enter the year your were born and return your current age

c program

15th Feb 2018, 7:56 AM
ian
ian - avatar
10 Answers
+ 4
Harsh Agrawal I don't know what you mean. I haven't disliked anything.
19th May 2018, 5:50 PM
Robyn A
Robyn A - avatar
20th May 2018, 8:53 AM
Robyn A
Robyn A - avatar
+ 2
#include<stdio.h> Main () { int born_year,current_year,Age; printf("Enter the year you were born "); scanf("%d,&born_year"); Age=current_year - born_year; printf("your age is %d", Age); return 0; }
15th Feb 2018, 9:00 AM
ian
ian - avatar
+ 1
Hi there. Is this your homework? Have you tried to make it first? If you have tried it and you're having problem with your code, you can post it here so we can help.
15th Feb 2018, 8:12 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
bro firsty u wll try then we wll solve the error!!!so it is also help for us nd u
15th Feb 2018, 8:54 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
class abc { int x,month,y; void accept(int q,int year_u_were_won) { month= q; x= year_u_were_won; } void current_age() { if(month>2 && month<=12){ y= 2017-x; } else if(month<2 && month>=1){ y= 2018-x; } System.out.println(y); } public static void main(String args[]) { abc ob= new abc(); ob.accept(5,2002); //enter your born year ob.current_age(); } } // hope this will help you....
15th Feb 2018, 9:08 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
in your code there is an error, scanf ("%d", &born_year), then there isn't the request to current year
15th Feb 2018, 9:26 AM
Pegasum
Pegasum - avatar
+ 1
Robyn A oh but in my mobile its show that u dislike my code but if u say that u r nt then its okkkk no problem
20th May 2018, 6:48 AM
Harsh Agrawal
Harsh Agrawal - avatar
0
#include<stdio.h> Main () { int born_year,current_year,Age; printf("Enter the year you were born "); scanf("%d,&born_year"); current_year=2018; Age=current_year - born_year; printf("%dyou age is\n", Age); system ("pause") return 0;
15th Feb 2018, 2:50 PM
ian
ian - avatar
0
Robyn A why u put dislike?is there any problem in code? if yes then make me beware of this? nd if no then make it by yourself.....dont put dislike as i wll be thinking that u were nt able to solve this question.......please dont get me wrong as i just guide you....rather according to your xp u are too.....gud
15th Feb 2018, 2:54 PM
Harsh Agrawal
Harsh Agrawal - avatar