Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

C Program to Check Leap Year

C Program to Check Leap Year

✅ C Program to Check Leap Year


#include <stdio.h>

int main()
{
    int year;

    printf("Enter a year: ");
    scanf("%d", &year);

    if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
        printf("%d is a Leap Year\n", year);
    else
        printf("%d is NOT a Leap Year\n", year);

    return 0;
}
  

πŸ“˜ Explanation:

This C program checks whether a given year is a leap year or not.

A year is a leap year if:

  • It is divisible by 400, OR
  • It is divisible by 4 but not divisible by 100

These conditions are checked using logical operators and modulus (%) operator.

🧾 Sample Output:

Enter a year:
2024
2024 is a Leap Year
  

πŸ”‘ Keywords:

C leap year program, leap year logic in C, C conditional statements, C if else program, year checking in C

πŸ” Search Description:

Learn how to check whether a given year is a leap year in C programming with simple logic, explanation, and output.

πŸ“Œ Hashtags:

#CProgramming #LeapYear #CPrograms #ProgrammingBasics #1printf

Comments

Popular Posts

πŸŒ™