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; ...

Find Greatest of Three Numbers in C

Find Greatest of Three Numbers in C

✅ Find the Greatest of Three Numbers in C

#include <stdio.h>

int main() {
    int a, b, c;

    // Input
    printf("Enter three numbers:\n");
    scanf("%d %d %d", &a, &b, &c);

    // Logic to find greatest
    if (a >= b && a >= c) {
        printf("The greatest number is: %d\n", a);
    } else if (b >= a && b >= c) {
        printf("The greatest number is: %d\n", b);
    } else {
        printf("The greatest number is: %d\n", c);
    }

    return 0;
}
  

πŸ“˜ Explanation:

This C program takes three integers as input and determines the greatest among them using simple conditional statements. It compares the three numbers using nested if-else blocks:

  • First checks if a is greater than or equal to both b and c.
  • If not, then checks if b is greater than or equal to the other two.
  • If both conditions fail, then c is the greatest by default.
This approach ensures correct output even if the numbers are equal.

🧾 Sample Output:

Enter three numbers:
12 45 33
The greatest number is: 45
  

πŸ”‘ Keywords:

Greatest of three numbers, if else in C, compare numbers in C, logic building in C, beginner level C program, C programming basics

πŸ“Œ Hashtags:

#CProgramming #BeginnerC #MaxOfThree #ComparisonLogic #IfElseC #CodingBasics

Comments

Popular Posts

πŸŒ™