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

πŸŒ™