Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

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

πŸŒ™