Factorial of Given Num

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

FACE TCS Ninja - Coding_4

TEST CODE : TCS Ninja -


Coding_4
Total number of question : 1
Test duration (min) : 20 min
Correct attempt (mark) : NA
Wrong attempt (mark) : NA

CODING

Write a program to find the Factorial of the given number

#include <stdio.h>
int main()
{
long int fact=1;
int i,num;
//printf("\nPlease enter a number to find factorial : ");
scanf("%d",&num);

if (num<0)
{
//printf("\nPlease enter a positive number to");
return 1;
}
for(i=1;i<=num;i++)
{
fact=fact*i;
}
printf("%ld\n",fact);
return 0;
}

______________________________________________________________________________________________________
Focus Academy for Career Enhancement Page 1 of 1

You might also like