n00b needs help with small program
Hello all
I have always wanted to learn to program. I have started and quit many times. it is tough as a self-taught student. I found a good online course recently. I intend to see it through. Here is my first program. I need help from one of you :)
My challenge was to write a program that determines whether entered year is a leap year. If entered year is not a leap year, it should prompt for another year that is a leap year, not close. it should keep prompting for a leap year until it gets one.
So far I have it calculating whether it's a leap year or not..
Code:
#include <stdio.h>
#include <cs50.h>
int
main(int argc, char * argv[])
{
int x;
printf("Enter a year: ");
x = GetInt();
if( ((x % 4 == 0) && (x % 100 != 0)) || (x % 400 == 0) )
printf("The Year is a Leap Year");
else
printf("The Year is Not a Leap Year");
return 0;
}
So far so good. Now I need to figure out how to get it to loop and keep prompting for a leap year until it gets one.
It is my feeling that this needs a DO WHILE loop... although I am not sure.. nor do I know quite how to write it.
Can you help me?
Please?
Thanks much
-Noob