Hello. So im a little bit stuck on one of my homework questions.
heres the question:
Write a C Shell Script that performs the following functions. Asks the user to input a year. The script should then calculate whether or not the year is a leap year. The script should caculate whether or not it is a leap year using the following algorithm. A leap year is defined as any year divisible by 4 but not by 100. However, if a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. The script should implement the math to produce this algoritm and tell the user whether or not the year entered is a leap year.
heres what i have so far:
*************** *************** *************** *************** *
#!/bin/csh
echo Please input a year
set year = $<
if ( $year / 4 ) then
echo this is a leap year
else
echo this is not a leap year
endif
*************** *************** *************** ***************
i know its not exactly what the teacher wanted but i was just messing around with it to see if this could tell me whether or not it was a leap year and for every year i input it tells me its a leap year. i dont know what im doing wrong. any help would be helpful thanks
heres the question:
Write a C Shell Script that performs the following functions. Asks the user to input a year. The script should then calculate whether or not the year is a leap year. The script should caculate whether or not it is a leap year using the following algorithm. A leap year is defined as any year divisible by 4 but not by 100. However, if a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. The script should implement the math to produce this algoritm and tell the user whether or not the year entered is a leap year.
heres what i have so far:
*************** *************** *************** *************** *
#!/bin/csh
echo Please input a year
set year = $<
if ( $year / 4 ) then
echo this is a leap year
else
echo this is not a leap year
endif
*************** *************** *************** ***************
i know its not exactly what the teacher wanted but i was just messing around with it to see if this could tell me whether or not it was a leap year and for every year i input it tells me its a leap year. i dont know what im doing wrong. any help would be helpful thanks
Comment