prev | While-Loop 48. Prints Leap & non Leap years (21.7.2009) /* Program# 48 date : 28-12-2008 while loop-print leap years between 1980 to 2000 */ #include <stdio.h> main(){ int n,a; n=1980; while(n<=2000){ a=n%4; if(!a) printf("\n Leap Year:%d",n); else printf("\n Non Leap Year:%d",n); n=n+1; } } output: To compile the program, run the gcc command, $ gcc p48.c Now the executable file is stored as a.out, to run the program, $ ./a.out Leap Year:1980 Non Leap Year:1981 Non Leap Year:1982 Non Leap Year:1983 Leap Year:1984 Non Leap Year:1985 Non Leap Year:1986 Non Leap Year:1987 Leap Year:1988 Non Leap Year:1989 Non Leap Year:1990 Non Leap Year:1991 Leap Year:1992 Non Leap Year:1993 Non Leap Year:1994 Non Leap Year:1995 Leap Year:1996 Non Leap Year:1997 Non Leap Year:1998 Non Leap Year:1999 Leap Year:2000 $ |
next |