Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Working with switch case



Test expression



Header file



Specifer



Comment




Leap year in a range




// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int x,y,i,j; //taking the number to continue loop as start point pf("Enter first year: "); scanf("%d",&x); //taking the number to stop loop pf("\nEnter the second year: "); scanf("%d",&y); //in the loop calculation is running to find leap year for(i=x;i<=y;i++) { if(i%4==0) { if(i%100==0) { if(i%400==0) pf("\n%d is leap year.",i); else pf("\n%d is not leap year.",i); } else pf("\n%d is leap year.",i); } else pf("\n%d is not leap year.",i); } return 0; }
OUTPUT:


© 2018 - All rights reserved