asked 160k views
2 votes
5.Write a program that calculates the factorial of a given number (for example, factorial of 5 = 120).

1 Answer

6 votes

Answer:

Using c++ syntax

int givenNumber= 5; //can set to something else

int answer = 1;

for (int i = 1; i <= givenNumber; i++){

answer *= i;

}

answered
User Frank Eno
by
9.3k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.