1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AlladinOne [14]
3 years ago
12

Write a c++ program to calculate the factorial of a number

Computers and Technology
1 answer:
dangina [55]3 years ago
3 0

Answer:

#include <iostream>

int factorial(int n) {

 return (n > 1) ? n*factorial(n-1) : 1;

}

int main() {

 std::cout << factorial(5);

}

Explanation:

Above is an approach using recursion.

It will output 120, which is 5! = 5*4*3*2*1

You might be interested in
FREE 10 POINTS THE EASIEST QUESTION EVER I AM NEW SO I DONT KNOW HOW TO MARK SOMEONE THE BRAINLEAST ????????????????????????????
umka2103 [35]

Usually you can just report the question as useless or just report in in general. But I myself have read some answers and they dont even pertain to the question, it confuses me alot

8 0
3 years ago
Read 2 more answers
Which does a traditional camera need in order to capture images?
pashok25 [27]

Answer:

I think secure digital is needed

3 0
2 years ago
Samm1E49 ok my username is mosarider489 also if others want to join u can friend me
mixer [17]

Answer:

ok

Explanation:

3 0
2 years ago
Read 2 more answers
Is a ROUTER required for Internet Connectivity ?<br> Yes<br> No
Kazeer [188]

no it is not but u will need a ethernet cord

5 0
2 years ago
a _____ is a recreation of a thumbnail in a desktop publishing software, also known as a "rough". a. proof b. digital draft c. l
Dmitrij [34]
D. It’s a sketch. That is, if you talking about, an art piece.
6 0
2 years ago
Other questions:
  • What are the two different frequencies WiFi operates on?
    9·2 answers
  • Which two software interfaces allow adjustment of the cpu voltage? (choose two.)?
    10·1 answer
  • The INC and Dec instruction do not effect the__________ flag
    6·1 answer
  • A star appears under the <br> menu of the word processing program.
    5·1 answer
  • The radix sort
    14·1 answer
  • What operating system is an open source program
    15·1 answer
  • When Creating a FPS game what basic rules would you add?
    12·1 answer
  • Use the syntax SELECT ________ (expression) [Column Name] to limit the result set to the number of rows defined by the expressio
    10·1 answer
  • Answered
    10·1 answer
  • Cable inside the computer transferring data between the mother board and storage devices.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!