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 Find Factorial of a Number

C Program to Find Factorial of a Number

✅ C Program to Find Factorial of a Number

#include <stdio.h>
int main( )
{
    int num, fact = 1;
    printf("Enter the number:\n");
    scanf("%d", &num);

    for(int i = 1; i <= num; i++)
    {
        fact = fact * i;
    }

    printf("Factorial of %d is %d\n", num, fact);
}
  

πŸ“˜ Explanation:

This program calculates the factorial of a number using a for loop. The factorial of a number is the product of all positive integers less than or equal to that number.

  • Take a number as input from the user.
  • Initialize a variable fact with value 1.
  • Use a for loop from 1 to the given number.
  • Multiply each number with fact in every iteration.
  • Print the final factorial value.

Example: 5! = 5 × 4 × 3 × 2 × 1 = 120

🧾 Sample Output:

Enter the number:
5
Factorial of 5 is 120
  

πŸ”‘ Keywords:

C program factorial, factorial using for loop in C, number programs in C, loop examples in C, C programming basics, beginner C programs

πŸ“Œ Hashtags:

#CProgramming #FactorialProgram #LearnC #CodingForBeginners #ForLoop #NumberPrograms #1printf

πŸ” Search Description:

Learn how to calculate factorial of a number in C using for loop. Simple and beginner-friendly C program with explanation and sample output.

Comments

Popular Posts

πŸŒ™