Programming Resource
  ifleap.c
 
/* Filename     :   ifleap.c
* Function Name: main
* Written By : Prof. Kantila [kantila@gmail.com]
* Dated : 12th Dec 2006
* Modified on : 18th Dec 2006
* Purpose : Program to check the given year for leap year
* Arguments : None, Ask interactively
* Header files : stdio.h, string.h, ctype.h, leap.h, bool.h
*/
#include <stdio.h> /*Standard Input/Output functions required */
#include <string.h> /*strlen function required */
#include <ctype.h> /*isdigit, atol functions required */
#include "leap.h" /*leapf function required */
#include "bool.h" /*bool data type required */
int main(void)
{
long int y1=0;
char string[10];
short length,counter;
bool ok=false;
fputs("This will check the given year & display whether its a leap year or not...\n",stderr);
while(!ok)
{
fprintf(stderr,"Input year to check [1-999999999] : ");
fscanf(stdin,"%9s",string);
fflush(stdin);
length=strlen(string);
for(counter=0;counter<length;counter++)
{
if(!isdigit(string[counter]))
{
ok=false;
break;
}
else
ok=true;
}
if(ok)
{
y1=atol(string); /*ASCII to LONG INTEGER */
if(y1==0)
break;
fprintf(stdout,"Year %li is %s a leap year\n",y1,((leapf(y1))?"\b":"not"));
ok=false;
}
else
fprintf(stderr,"Invalid year!\a\a\n");
}
fprintf(stderr,"Thanks for using 'ifleap.exe' created at MEC, Bikaner.");
return 0;
}





 
 
  Today, there have been 7 visitors (7 hits) on this page!  
 
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free