Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



Specifer



Iterative statement



" ; " after loop



Comment




Function_ find leap year in range




// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h> #include<math.h> #define pf printf //function declaration int fact(int year, int x); void main() { int a,res,m; pf("Enter first number: "); scanf("%d",&a); pf("\nEnter the second number: "); scanf("%d",&m); //function call res=fact(a,m); return 0; } //function definition int fact(int year, int x) //function header //function body { int i; for(i=year;i<=x;i++) { if(i%4 == 0) { if(i%100 == 0) //checking censure year { 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); } }
OUTPUT:


© 2018 - All rights reserved