السؤال من كورس ال Programming الخاص بي

Write a program that reads a positive integer and computes the factorial

الجواب

/************************************************************************************
 Name        : ex12.c
 Author      : Mohamed Elsayed
 Description : Assignment 1 - Ex 12
 ***********************************************************************************/

#include 

int main()
{
    int input;
    long long fact = 1;
    int i;
    printf("Please enter the required number : ");
    scanf("%d",&input);
 
 /* Loop to calcuate the factorial for example (5! = 5 * 4 * 3 * 2 * 1) */
    for(i=1;i<=input;i++)
    {
        fact = fact * i;
    }
    printf("\nfactorial of %d is: %ld",input,fact);
    return 0;
}

 

لمزيد من التفاصيل يرجى التواصل معي

ابحث عن مسائل برمجة سي c | C programming بالانجليزي

هل أعجبك المحتوى؟

محتاج مساعدة؟ تواصل مع مدرس اونلاين الان!

التعليقات
لا يوجد تعليقات
لاضافة سؤال او تعليق على المشاركة يتوجب عليك تسجيل الدخول
تسجيل الدخول