0% found this document useful (0 votes)
54 views1 page

Factorial of Given Num

The document contains a coding test summary with details of the test such as the test name "TCS Ninja - Coding_4", number of questions which is 1, and duration of 20 minutes. It also provides the coding question which is to write a program to calculate the factorial of a given number by taking the number as input, initializing the factorial variable, using a for loop to calculate the factorial and print the result.

Uploaded by

Pranay Mudhiraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

Factorial of Given Num

The document contains a coding test summary with details of the test such as the test name "TCS Ninja - Coding_4", number of questions which is 1, and duration of 20 minutes. It also provides the coding question which is to write a program to calculate the factorial of a given number by taking the number as input, initializing the factorial variable, using a for loop to calculate the factorial and print the result.

Uploaded by

Pranay Mudhiraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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