Header Ads Widget

C program to check if the year is leap year or not

 #include <stdio.h>


int main() {

   int year;

   

   printf("Enter a year: ");

   scanf("%d", &year);


   if (year % 4 == 0) {

      if (year % 100 == 0) {

                                 if (year % 400 == 0)

                                  printf("%d is a leap year.", year);

                                else

                                   printf("%d is not a leap year.", year);

      }

      else

         printf("%d is a leap year.", year);

   }

   else

      printf("%d is not a leap year.", year);


   return 0;

}

/* 15 number   to find laep year 

Check if the year is divisible by 4. If it is, move to step 2. If it is not, then it is not a leap year.


Check if the year is divisible by 100. If it is, move to step 3. If it is not, then it is a leap year.


Check if the year is divisible by 400. If it is, then it is a leap year. If it is not, then it is not a leap year.


For example, 2020 is divisible by 4, so it moves to step 2. It is not divisible by 100, so it is a leap year.


if (year % 4 == 0)  yes ma divide and if remainder ==0then only it wll move on or else ma janxa

 */ 






Post a Comment

4 Comments

  1. looop #include
    void main ()
    {
    int i;

    for (i = 0; i <= 1000; i = i++) {
    printf("%d\n", i);
    }


    }

    ReplyDelete
  2. 23 number ko #include
    void main ()
    {
    int i;

    for (i = 0; i <= 41; i = i+4) {
    printf("%d\n", i);
    }


    }

    ReplyDelete
  3. print astrek


    #include
    int main(){

    int i, j ;

    for (i= 0 ; i<=5; i++)
    {
    for (j=0; j<=i; j++)
    {
    printf("*");
    }
    printf("\n");
    }
    }

    ReplyDelete
  4. #include
    void main()
    {
    int i,j;
    for(i=1;i<=5;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",i);
    }
    printf("\n");
    }
    }





    1
    22

    ReplyDelete