- 2
Write a c program that will ask you to enter the year your were born and return your current age
c program
11 Answers
+ 4
Harsh Agrawal I don't know what you mean. I haven't disliked anything.
+ 4
+ 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;
}
+ 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.
+ 1
bro firsty u wll try then we wll solve the error!!!so it is also help for us nd u
+ 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....
+ 1
in your code there is an error, scanf ("%d", &born_year), then there isn't the request to current year
+ 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
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;
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