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

Answers

Answer 1

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

Answer 2
CODE

#include <iostream>

using namespace std;

int main() {

   // Declare the variables

   int n = 19;

   long int factorial = 1;

   // Each time, the factorial multiplies by integers from 1 to the maximum number.

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

       factorial = factorial * i;

   }

   

   // Display the factorial

       cout << factorial;    

   return 0;

}

EXPLANATION

Declare n and factorial as integers and long integers.

The "for loop" runs from 1 to the maximum number and increments by 1. The factorial multiplies each time by integers from 1 to n.

Print the factorial.


Related Questions

What are the three benefits of incremental development, compared to the waterfall
model?

Answers

Answer:

The cost of accommodating changing customer requirements is reduced

The primary purpose of the SNORT application is to function as an ACL, i.e. it controls authorization (or access) to a resource.
O True
O False

Answers

SNORT is the powerful IDS and IDS (IPS) program that enables real-time traffic data and analytical packet logging. It delivers a sophisticated IDS system to detect potential malicious activities. It employs a common language that integrates animality, protocol, and signatures analysis methodologies.It is used to monitor traffic in and out of a network utilized. It monitors travel in real-time and sends users alerts to detects potentially malicious packets or dangers on the IP networks.It analyses and searches for the content and matches protocols.

That's why the answer is "False".

Learn more:

brainly.com/question/14288353

in Adobe illustrator cc 2017 which of the following export file ​

Answers

Explanation:

In Adobe illustrator cc (2017) , of the following export file formats cannot preserve transparency

Any computer expert to help me answer this question.. am giving brainliest

Answers

Answer and explanation:

1. It asks for the total expenses for the month of March. So, let's add all of the March expenses up.

1,600 + 2,100 + 850 + 480 + 2,800 = $7,830 (which is the answer)

2. It asks what the highest expense for wages are. That would be $5,080. Out of all of the times that the wages have been paid, in April, it was the highest, at $5,080. So, $5,080 is the answer.

3. It asks how many items cost less than $1,000 in April. The only thing that cost less than $1,000 in April was the water because it only cost $370. So, the answer would be 1.

Hope this helps!


When is innovation good, and when is it problematic?

Answers

Answer:

Innovation is the ability to change the course of the future. ... Finally, innovation is neither good nor bad, however, it is always new. When done correctly it has the power to impact, improve and change the way we live, work and interact. Every company should aspire to be a leader in innovation

Explanation:

CSS At-rules provide a way for designers to define "if this, then that" scenarios.
True or false?

Answers

True true true true

When we say that communication is relational, what does that mean?
a. Communication is key to greater satisfaction in relationships.
b. Communication involves a wide range of socially appropriate behaviors.
c. Communication is something that we do to others.
d. Communication arises out of our interactions with others.

Answers

Answer:

a

Explanation:

Without communication there's nothing we can do .

Relational interaction includes the processes of interaction in personal relationships like romantic relations, family ties, and friendships, and further discussion can be defined as follows:

It consists of negotiating processes by which the dyadic partners define who they are and they will collaborate. This relation perspective assumes that the pair is indeed the best unit for interpersonal communication observation.

Therefore, the final answer is "Option a".

Learn more:

brainly.com/question/12062755

Should robots be programmed to think? What are some positive and negative aspects? explain

Answers

Answer:

Positive affectivity refers to positive emotions and expression, including cheerfulness, pride, enthusiasm, energy, and joy. Negative affectivity is negative emotions and expression, which includes sadness, disgust, lethargy, fear, and distress.

How was science used to make television?

Answers

Answer:

Sir William Crookes invented the cathode ray tube in 1878, but these discoveries took many years to merge into the common ground of television. ... His mechanical system used a scanning disk with small holes to pick up image fragments and imprint them on a light-sensitive selenium tube. A receiver reassembled the picture.

Television is really a three-part invention: the TV camera that turns a picture and sound into a signal; the TV transmitter that sends the signal through the air; and the TV receiver (the TV set in your home) that captures the signal and turns it back into picture and sound.

https://www.jstor.org/stable/20024824 ( This link is helpful)

Mouse is .....ware.

Answers

Mouse is hardware.

Explanation:

because we can touch it and in the hardware definition we say that it can be touched.

What was revolutionary about Web 2.0?

Answers

Answer:

social media and sites allow people to communicate with others

Explanation:

Hope this helps <3

Data modeling may be the most important part of the systems development process because: Group of answer choices data are less stable than processes. data characteristics are important in the design of programs and other systems components. it is the easiest. the data in a system are generally less complex than processes and play a central role in development.

Answers

Answer:

please mark me brainlist

Explanation:

Memory Uninstalling a program

A) Removes the program from memory

B) Removes the program from a disk

C) Removes the program from the monitor

D) Permanently removes a program that is no longer
wanted

Answers

Answer:

D

Explanation:

but you can re install it

write a c++ program to find the factorial of a number.

Answers

Answer:

I'm not gonna use recursion for this program.

#include <iostream>

using namespace std;

int main()

{

int input,factorial=1;

cout<<"Enter a number to get it's factorial: ";

cin>>input;

for(int i=1;i<=input;i++)

{

factorial *=i;

}

cout<<"The factorial of the number you entered is: "<<factorial;

return 0;

}

#include
using namespace std;
int main() {
int num,factorial=1;
cout<<" Enter Number To Find Its Factorial: ";
cin>>num;
for (int a=1;a<=num;a++) {
factorial=factorial*a;
}
cout<<"Factorial of Given Number is ="< return 0;
}

For those of u who watch Lucifer- S6 is coming out on Sept 10th

Answers

Ight ty for the info

The first electric, general-purpose computer, ENIAC, was programmed by

Answers

Answer:

Designed by John Mauchly and J. Presper Eckert, ENIAC was the fastest computational device of its time, able to do 5,000 additions per second, but because it had no internal storage, it had to be programmed manually for each new set of calculations.

Suppose now the file is broken up into 1000 packets with each packet
containing 4,000 bits. Suppose that each packet is acknowledged by the
receiver and the transmission time of an acknowledgement packet is
negligible. Finally, assume that the sender cannot send a packet until the
preceding one is acknowledged. How long does it take to send the file?

Answers

Answer:

The delay to send each packet will be ttrans + tprop. However there is an  additional tprop delay for the acknowledgement packet to arrive at the sender, prior  to which the next packet can be transmitted. Hence the total delay to transmit 10  packet is = 10 * (ttrans + 2 tprop) = 10*(40 msec + 80 msec) = 1.2 sec

Explanation:

What are the different types database of end users? Discuss the main activi-ties of each

Answers

Answer:

following types of databases available in the market −

Centralised database.

Distributed database.

Personal database.

End-user database.

Commercial database.

NoSQL database.

Operational database.

Relational database.

Cloud database.

Object-oriented database.

Graph database

Answer:

1. Casual End Users

These are the users who occasionally access the database but they require different information each time. They use a sophisticated database query language basically to specify their request and are typically middle or level managers or other occasional browsers. These users learn very few facilities that they may use repeatedly from the multiple facilities provided by DBMS to access it.

2. Naive or parametric end users

These are the users who basically make up a sizeable portion of database end users. The main job function revolves basically around constantly querying and updating the database for this we basically use a standard type of query known as canned transaction that have been programmed and tested. These users need to learn very little about the facilities provided by the DBMS they basically have to understand the users’ interfaces of the standard transaction designed and implemented for their use. The following tasks are basically performed by Naive end users:

The person who is working in the bank will basically tell us the account balance and post-withdrawal and deposits.

Reservation clerks for airlines, railway, hotels, and car rental companies basically check availability for a given request and make the reservation.

Clerks who are working at receiving end for shipping companies enter the package identifies via barcodes and descriptive information through buttons to update a central database of received and in transit packages.

3. Sophisticated end users

These users basically include engineers, scientist, business analytics and others who thoroughly familiarize themselves with the facilities of the DBMS in order to implement their application to meet their complex requirement. These users try to learn most of the DBMS facilities in order to achieve their complex requirements.

4. Standalone users

These are those users whose job is basically to maintain personal databases by using a ready-made program package that provides easy to use menu-based or graphics-based interfaces, An example is the user of a tax package that basically stores a variety of personal financial data of tax purposes. These users become very proficient in using a specific software package.

Shift all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would become 25 1 4 9 16.

Answers

Answer:

i see you but i dobt see it

Explanation:

When you use an IDE instead of a simple text editor to develop a program, ____________.

Answers

Answer:

your answer is :

some help is provided

Explanation:

An integrated developed environment (IDE) provide more programming help than a plain text editor.

please mark me brainlist

general description of the problem

Answers

Explanation:

problem is the misunderstanding misbehaviour etc which harm us and others

A matter or situation regarded unwelcome or harmful is known as problem

que es una red de datos

Answers

Answer:

donde se guarda information o a dode sebuca

Which of the following choices BEST explains the purpose of developing a research plan?
A.
Research plans are ONLY used by teachers to plan their daily classroom activities.
B.
Research plans are ONLY used by experts who have to write articles for scholarly journals in various fields.
C.
Research plans are used by any person who is critically evaluating a topic; since research papers involve multiple stages and multiple sources, the writer uses the plan for time management.
D.
A research plan is the term to describe the research paper and the bibliography.



Please select the best answer from the choices provided


A
B
C
D

Answers

Answer:

C

Explanation:

Because the research is for everybody

This number is written in binary (base 2). Convert it to decimal (base 10).



10110110

Answers

Answer:

Binary 10110110

Decimal 182

Hexadecimal B6

Bits 8

Equation 128 + 32 + 16 + 4 + 2

Explanation:

https://www.binary-code.org/binary/8bit/10110110/

Have a bless day and send positive all over the world :D

Basic function call get_pattern() returns 5 characters. Call get_pattern() twice in a print() statement to return and print 10 characters. Example output: ***** *****
def get_pattern():
return '*****'
print('*****')
print('*****')
get_pattern()
get_attern()
Testing pattern returned was printed twice.
Your output
*****
*****
Testing with different character. Output differs. See highlights below.
Your output
*****
*****
Expected output
#####
#####

Answers

Answer:

get_pattern()

get_pattern()

print(get_pattern())

print(get_pattern())

Explanation:

The program is given in Python; this means that it must be completed in Python.

The code segment that completes the program is:

print(get_pattern())

print(get_pattern())

From the complete question, the given code segment is:

def get_pattern():

    return '*****'

The above function will only return 5 characters i.e. 5 *'s, but it will never print the characters.

For the characters to be printed, a print statement must be introduced when calling the function get_pattern()

So, the print statement will be:

print(get_pattern())

The question requires 10 characters; so, the print statement must be called twice.

Hence, the code segment that completes the program is:

print(get_pattern())

print(get_pattern())

Read more about Python programs at:

https://brainly.com/question/22841107

Consider the LIBNAME statement below: LIBNAME 'path-to-file'; TRUE/FALSE: The name of the SAS library you are creating must match the name of the folder it references.

Answers

The SAS Library is a collection of a SAS file or more that is SAS recognized and stored as a unit.

Every file is a library member, it assists you to get your job organized. It consists of all your files in the same library if a SAS program needs or more than one SAS.A logical name termed a libre is a reference in a SAS library. The single SAS library can't store files at various physical sites, in which SAS deletes the temporary SAS library contents but not SAS libraries.

That's why the given statement is "false".

Learn more:

brainly.com/question/14354148

How many bits would be needed to count all of the students in class today? There are 16 children in the class.

Answers

Answer:

There will be 23 beats per children

what separates the components of a domain name

Answers

Explanation:

period

In a domain name, the 'thing' that separates its components is a period.

IPO cycle eexample three examples

Answers

ATM machine.
micro oven.
washing machine.
making tea.
calculator.

Which are the correct commands to create and run an ReactJS project?

npm create-react-app my-app && cd my-app && npx start
npm create-react-app my-app && cd my-app && npm start
npx create-react-app my-app && cd my-app && npx start
npx create-react-app my-app && cd my-app && npm start
npx create-react my-app && cd my-app && npm start

Answers

Answer:

Step 1: Initialize NPM (Node Package Manager) mkdir new-react-app cd new-react-app npm init --y. ...

Step 2: Install React, Webpack, and Babel. ...

Step 3: Create the files. ...

Step 4: Create NPM run scripts.

Other Questions
if you were the head of your school , what would be your duties and responsibilities to manage the school? write briefly. What is the wordonly smart people Why is it dangerous to get ideas of what health looks like from non-medical sources, like social media? List the steps of the scientific methodEasy points, just don't be annoying. The form GUSTAN is used with ________. *order of operation296-(652-32/4 1/7 x X =1 X x 1/11=11 divided by 1/5= Determine how fast you are driving if it takes you 50 seconds to drive from one mile marker to the next. A supervisor wants to know the average number of hours worked by employees in a factory. There are 18 managers, 240 laborers, and 54 administrators. Three managers are chosen to participate in the survey. In order for the sample to accurately represent the population, about how many administrators should be chosen? What type of light does this light bulb produce most (i.e. at what wavelength does the spectrum have maximum intensity)?Hint: Refer to the image of the electromagnetic spectrum at the beginning of the assignment.Infrared lightRed visible lightViolet visible lightUltraviolet light what might of been the population of vermont in 2008??? Will give BRAINLIST HELP ME ASAPHow many states sent delegates to the AnnapolisConvention in 1786?A. None of the states sent delegatesB. Less than half of the states sent delegatesC. More than half of the states sent delegatesD. All of the states sent delegates Which of the following is the best example of a behavior?a. walking the dogb. thinking about what you are gonna eat c. remembering what class you are in d. feeling so happy about the good news How many are there mouse actions performed by two mouse button. Well I need help in number 11, the equation is D=V0T Belle ran a total of 510 meters directly toward school at a constant velocity. She ran one-thirdof that distance in 85 seconds. What was her velocity?HELP ASAP PLZZZ BEING TIMED What ecological levels does not describe interacting biotic and abiotic factors in an area Prompt: In what ways does transformation play a role in stories that are meant to evoke intense emotions? advantages and disadvantages of chemistry which one of the following properties does not give the water the ability to become asuitable medium for chemical reactions