Today we are going to discuss some important Accenture Coding Questions and answers that has been asked in previous years for engineering Fresher hiring.
So, If you are also appearing in Accenture, then there are fair chances that you can get same difficulty level of questions in your actual exam.
Given ‘a’ (1<=n<=100), find the factorial of ‘n’. The factorial of ‘n’ is defined as the product of all integers.
Input specification:
Input : any number ‘n’
Output Specification:
Return a string containing the factorial.
Example 1:
Input : 5
Output: 120
Explanation:
5!=5*4*3*2*1 = 120
Example 2:
Input 1: 6
Output: 720
Explanation: 6!=6*5*4*3*2*1 = 720
Solution in C :
#include<stdio.h>
int main()
{
int number;
long i,fact = 1;
scanf("%d",&number);
for(i=1;i<=number;i++)
fact=fact*i;
printf("%ld",fact);
return 0;
}
Output:
5
120