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

The output signal from an analogue sensor is sampled every 195 µs to convert it into a digital representation. What is the corresponding sampling rate expressed in kHz?
According to the Sampling Theorem, for this sampling rate value, what approximately could be the highest frequency present in the signal, in kHz, assuming the lowest frequency is very close to zero?

If each sample is now quantised into 512 levels, what will be the resulting bitrate in kbps?

Give your answer in scientific notation to 2 decimal places.

Hint: you need to determine the number of bits per sample that produces 512 quantisation levels.

Answers

Answer:

A sample rate is just reciprocal of the sample period. According to sampling theorem the highest frequency in single would be [tex]5.13/2=2.565 KHz.[/tex][tex]2^8=512[/tex] So you will need 8 bits to represent.[tex]8 bits \times5.128\times(10)^3[/tex]samples [tex]=41.026[/tex] bits per second.

Explanation:

Sample period of 1 millisecond [tex]=1 kHz.[/tex]

Thus a sample period of [tex]0.195[/tex] milliseconds is

[tex]1/0.195=5.12820513 Hz[/tex]

To determine the sample after [tex]512[/tex] levels quantization, we need to find bits per sample that produces [tex]512[/tex] quantization levels.

Thus,

[tex]2^8=512[/tex]

So you will need 8 bits to represent.

8 bits [tex]\times5.128\times(10)^3[/tex] samples [tex]=41.026[/tex] bits per second.

Learn more about scientific notation, refer :

https://brainly.com/question/10401258

Sample outputs with inputs 9 5 2 -1 in python.

Answers

Sorry phsnjajajajqjkakw

In what ways are computers being used to improve our quality of life

Answers

Answer:

computers help with our education systemcommunicating with others is easier (emails/text messages opposed to sending an envelope)technological advances

Computer is the electronics devices which input process and output the results.
It helps in education in this pandemic condition we are able to have class through Internet in computers
We use computers in offices to generate income
We run hospital works to computer to outcome the result of patients

we can not split the cell true or fasle​

Answers

Answer:

You can't split an individual cell.

Explanation:

You can't split an individual cell, but you can make it appear as if a cell has been split by merging the cells above it.

The digital system usually operated on?

Answers

Answer:

The digital systems usually operate on binary number system.

What are the benefits of transferable skills? Check
all of the boxes that apply
-They are easier to develop than job spectie
skills
-They help a person develop self esteen
-They are necessary for job advancement
-They allow easy cross-company transfers
-They open up a variety of employment
options
-They can replace many IT Skills.

Answers

Answer:

Option 1,2,4,5 are correct ..

Explanation:

mark me as brainliest ❤️

Which of the following computers would be used in a large corporation to complete huge processing needs, such as airline reservations?​

Answers

A mainframe computer, informally called a mainframe or big iron, is a computer used primarily by large organizations for critical applications like bulk data processing for tasks such as censuses, industry and consumer statistics, enterprise resource planning, and large-scale transaction processing. I could be wrong though

15. Virus cannot infect files that are saved in i. USB ii. CD-ROMs iii. Memory card iv. All of them​

Answers

Answer:

all of them

Explanation:

but Virus can infect them if u plug them in infected computer .

Answer: CD Roms.  Virses can infect each other item by actually writing to the device.  For CD Roms, you must have a special writer program to write to the ROM.  

Explanation:

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;
}

where do I go to ask help from a tech and internet expert. security and protection. I'm open to suggestions and guesses​

Answers

Answer:

from my own experience, the best place to call is your local Best Buy store. they have a group of technicians called the Geek Squad, and you can either call them for tech support or protection suggestions, or have them do maintenance on a device (both in store and at home)

Which model of communication focuses on the meaning that emerges in a relationship between communicators?
a. Transactional
b. Symbolic
c. Complementary
d. Linear

Answers

Answer:

QUESTION

Which model of communication focuses on the meaning that emerges in a relationship between communicators?

[tex]==============================================

[/tex]

CHOICES

a. Transactional

b. Symbolic

c. Complementary

d. Linear

[tex]==============================================

[/tex]

ANSWER

a. Transactional

[tex]==============================================

[/tex]

#CarryOnLearning

(◕ᴗ◕✿)

Worksheet-I • Make a list of 10 application software and 5 utility programs installed in your computer, along with their uses. Uses Applications Type​

Answers

Answer:

An antivirus is a utility software that helps to keep the computer virus-free. Moreover, it notifies when any malicious file is detected and removes such files. In addition, it scans any new device attached to the computer and discards any virus if there. Moreover, it also scans the system from time to time for any threats and disposes of them. Examples of antivirus are McAfee Antivirus, Quick heal Antivirus, Windows Defender, etc.

These utility software are used to manage files of the computer system. Since files are an important part of the system as all the data is stored in the files. Therefore, this utility software help to browse, search, arrange, find information, and quickly preview the files of the system.

An important part of a computer is storage space, it is very important to maintain this storage. Therefore, we use certain utility software to compress big files and decrease their size, these are compression tools. The format of the files changes while compressing and we cannot access or edit them directly. In addition, we can easily decompress the file and get the original file back. Examples of compression tools are WinZip, WinRAR, 7-Zip, etc.

These utility software are used to manage data on disks. Moreover, they perform functions like partitioning devices, manage drives, etc. Examples of disk management tools are Mini Tool Partition Wizard, Paragon Partition Manager, etc.

This utility software helps to free up the disk space. In addition, the files which are no longer in use are removed from the disk. Examples are Cortex, C Cleaner, etc.

Explanation:

hope it helps

mark as brainiest

happy to help

ask more I'll help if I know the answer

jjhb ft fv tuning Denise l Debbie

Answers

What








What the debbie



Answer: is Debbi

Explanation: and what

What was the fisrt computer?

Answers

Answer:

AtanasoffBerry Computer.  It was built by physics Professor John Vincent Atanasoff and his graduate student, Clifford Berry, in 1942 at Iowa State College, now known as Iowa State University.

Explanation:

The First computer is called The Babbage Difference Engine.

I hope this is what you needed

20pts! WILL MARK BRAINLIEST ANSWER FAST PLZ!

A ______ is the equivalent of an electronic doorway between a network and a node ​

Answers

Answer:

I think its wan..........

Answer:

i think it might be "header"

Explanation:

Which bar displays the name of the application?

Answers

Answer:

Title bar displays the name of the application.

How far should robots be allowed to influence people's lives?

Answers

Answer:

robots should be allowed to influence people's lives in a limit because we don't know the future if because of this small mistake robots can rule us so , we should be prepared from now

Which part of a powertrain control module retains diagnostic trouble codes (DTCs), freeze-frame data, and learned data

Answers

Answer:

Memory and storage section

Explanation:

in MS Word we can merga cells​

Answers

I do not understand your question could you change it?

Your question doesn’t make any sense

Selection sort starts at the beginning of the list and compares pairs of data items as it moves down to the end.
a) true
b) false

Answers

Answer:

false

Explanation:

Hope, it helps to you

What are some of the innovations that colored television has undergone since its original invention? (include the date of the innovation)

Answers

Answer:

Color television was sold to viewers as a way to experience everything from sports and nature to musical theater in a more legible, realistic, captivating, and sensational way.

Explanation:

What the central difference between negative and positive politeness?

Answers

Answer:

      Politeness is universal, resulting from people's face needs: Positive face is the desire to be liked, appreciated, approved, etc. Negative face is the desire not to be imposed upon, intruded, or otherwise put upon.

    Positive face refers to one's self-esteem, while negative face refers to one's freedom to act. Participants can do this by using positive politeness and negative politeness, which pay attention to people's positive and negative face needs respectively.

What are positive face needs?

  One's face need is the sense of social value that is experienced during social interactions. Positive face refers to the need to feel accepted and liked by others while negative face describes the will to do what one wants to do with freedom and independence.

Negative politeness :

  Making a request less infringing, such as "If you don't mind" or "If it isn't too much trouble"; respects a person's right to act freely. In other words, deference. There is a greater use of indirect speech acts.

What is politeness in discourse analysis?

    In sociolinguistics and conversation analysis (CA), politeness strategies are speech acts that express concern for others and minimize threats to self-esteem ("face") in particular social contexts.

Hope u got it

If you have any question just ask me

How could the company benefit by applying Agile principles?

Answers

Answer:

The company could benefit by applying Agile principles managers' job easier and allows them to have greater control over their projects.

1.
In which of the following situations should you use your
vehicle's hazard lights?
A. You're stopped on the side of the road with an engine that won't start.
B. You're driving toward the shoulder because you hear a strange noise.
C. You're driving in the rain and your headli
s aren't functioning.
D. You're driving slowly because you just spilled coffee on your lap.

Answers

Answer:

B

Explanation:

trust

State the major different between fours types of computers

Answers

Answer:

1. Supercomputers

Supercomputers are very expensive and very fast. They are the most powerful computers we have in the world.

Supercomputers are optimized to execute only a small number of programs. This makes it possible for them to execute these few programs at a very high speed. Due to their inhibiting cost, they are used in high-end places like in scientific research centers. The supercomputer consists of thousands of processors, allowing it to clock in at very high speeds measured by petaflops.

These computer types are also very large in size due to the numerous parts and components involved in their design.

A good example of a supercomputer is Tianhe-2, which is located in the National Supercomputer Center in Guangzhou, China. It features 3.12 million cores, allowing it to run at speeds of 33.86 petaflops.

2. Mainframe Computers

These are large and expensive computers that are capable of supporting thousands of users simultaneously. They are mostly used by governments and large organizations for bulk data processing, critical applications, and transaction processing. They are ranked below supercomputers.

3. Minicomputers

Minicomputers are mid-sized computers. In terms of size and power, they are ranked below mainframes. A minicomputer is a multiprocessing system capable of supporting from 4 to about 200 users simultaneously.

The use of the term minicomputer has diminished since the introduction of microprocessors. These machines are now more commonly called midrange computers.

4. Microcomputers

A microcomputer, also known as a personal computer, is designed to be used by one user at a time. The term microcomputer relates to the microprocessor that is used for the purpose of processing data and instruction codes. These are the most common computer types since they are not very expensive

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:

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:


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:

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

You have just installed anti-malware software on all computers on your company's network. Which of the following additional actions would be BEST to take to help protect systems from malicious software?
a. Train users to scan removable storage devices before copying files
b. Disconnect all computers from the internet.
c. Require strong passwords in the local security policy.
d. Configure all computers with a screen saver password.
e. Configure the software to automatically update its definition files.

Answers

Answer:

The answer is A, E

Explanation:

Other Questions
Explain why you might want to write very large and very small numbers like the ones in the example problem in scientific notation. Why do you think that no country has become completely capitalist/free market economy? Why would most countries not want to do that? 1/#/test playerO100%For a party, Svetlana brought 4 packages of cookies with 16 cookies in each package. She and her friends ate all but 6 cookies,Which equation can be used to find C, the total number of cookies they ate?O A, C = (4x 16) + 6OB, C = (4 + 16) - 6OC, C = (6 x 16) - 4OD. C = (4x 16) - 6O E C = (6 + 16) + 4 What two areas of your body (related to the skeletal system) would be impacted by prolonged periods of sitting and typing How is a public corporation controlled What is the equation for a line that passes through the points (2,-2) and (-4,16)? what is the purpose of the database is characteristics of computer with definition Describe how scientific investigations lead to new scientific questions. How does ocean pollution relate to conservation? effect of taking drugs To join a new fitness center, there is a $50 initiation fee. It costs an additional $10 for every spinning class you attend. What is the average cost per class if you take 10 classes in the first month of joining the fitness center?A. $6B. $10C. $15D. $20HOW DO I DO THIS? In the sentence below, identify the pronoun and name its case.Alice lost her black sweater.Pronoun: _______Case: _______ (Type nominative, objective, or possessive .) help me pls im timed Evaluate the expression below.6(655+884)+1 define the lack of basic services please help i dont know this Clarisse is selling lemonade in her front yard for $0.50 per glass. Each glass is 1/8 of a pitcher. How much money can she make if she sells 5 pitchers? I have no ideas what this means at all. Please help me. Major grade questions please make sure its right