Newbie need help in repeating a program after user input
Hi,i am currently having problem with the following code. I want the program to ask the user whether he wants to repeat himself at the end of the program.This is what i come up with and i am not sure why it doesn't work.Hope u all can help me.THANK!
Code:
#include <stdio.h>
int main(void){
int age;
char answer;
do{
printf("Please enter a number between 1 and 100.\n");
scanf("%d", &age);
if (age>= 1 && age<= 20 )
printf("you are very young\n");
else if (age> 20 && age<= 50 )
printf("you are old\n");
else {
printf("u are very old\n");
}
printf("Do u want to continue?\n");
scanf("%c",&answer);
printf("\n");
}while (answer ='Y');
}