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
Rashid [163]
3 years ago
10

Write a while loop that will figure out the factorial of 5 (5!) and print this. It should use two integer variables (i and f) an

d print f at the end:
Computers and Technology
1 answer:
Hoochie [10]3 years ago
7 0

<u>Answer:</u>

<em>void main() </em>

<em>{ </em>

<em>int n, i, fact=1; </em>

<em>printf(""Enter the number\n""); </em>

<em>scanf(""%d"",&n); </em>

<em>i=num </em>

<em>while(i>=1) </em>

<em>{ </em>

<em>fact=fact * i; </em>

<em>i--; </em>

<em>} </em>

<em>printf(""The factorial of given number %d is %d\n"", n, fact); </em>

<em>return 0; </em>

<em>} </em>

<u>Explanation:</u>

This program obtains the number for which the factorial has to be found.

Then run a for loop till the factor of 1 is calculated and inside the for loop the number is multiplied with <em>other numbers in the descending order and finally result is printed. </em>

You might be interested in
Why was unicode invented?
lilavasa [31]
Unicode is a universal computing standard to represent texts in most writing systems. It was invented to store most of the world's characters. It started during 1987. Joe Becker from Xerox was the one who made a proposal for Unicode.
6 0
3 years ago
Read 2 more answers
2) [13 points] You’ve been hired by Banker Bisons to write a C++ console application that determines the number of months to rep
Paha777 [63]

Answer:

Check the explanation

Explanation:

CODE:

#include <iostream>

#include <iomanip>

using namespace std;

double getLoanAmount() { // functions as per asked in question

double loan;

while(true){ // while loop is used to re prompt

cout << "Enter the car loan amount ($2,500-7,500): ";

cin >> loan;

if (loan>=2500 && loan <= 7500){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< loan << " is an invalid loan amount." << endl;

}

}

return loan;

}

double getMonthlyPayment(){ // functions as per asked in question

double monthpay;

while(true){ // while loop is used to re prompt

cout << "Enter the monthly payment ($50-750): ";

cin >> monthpay;

if (monthpay>=50 && monthpay <= 750){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: $"<< monthpay << " is an invalid monthly payment." << endl;

}

}

return monthpay;

}

double getInterestRate(){ // functions as per asked in question

double rate;

while(true){ // while loop is used to re prompt

cout << "Enter the annual interest rate (1-6%): ";

cin >> rate;

if (rate>=1 && rate <= 6){ // if the condition is fulfilled then

break; // break statement is use to come out of while loop

}

else{ // else error message is printed

cout << "Error: "<< rate << "% is an invalid annual interest rate." << endl;

}

}

return rate;

}

int main() {

cout << setprecision(2) << fixed; // to print with 2 decimal places

int month = 0; // initializing month

// calling functions and storing the returned value

double balance= getLoanAmount();

double payment= getMonthlyPayment();

double rate= getInterestRate();

rate = rate /12 /100; // as per question

// printing as per required in question

cout << "Month Balance($) Payment($) Interest($) Principal($)"<< endl;

while(balance>0){ // while the balance is more than zero

month = month + 1; // counting Months

// calculations as per questions

double interest = balance * rate;

double principal = payment - interest;

balance = balance - principal;

// printing required info with proper spacing

cout <<" "<< month;

cout <<" "<< balance;

cout <<" "<< payment;

cout <<" "<< interest;

cout <<" "<< principal << endl;

}

cout << "Months to repay loan: " << month << endl; // displaying month

cout << "End of Banker Bisons";

Kindly check the output in the attached image below.

5 0
3 years ago
Mrs. Patel uses a computer program to balance her checkbook. Which of the following best explains how the
Alexandra [31]

Answer:

c it reduces errors

Explanation:

Instead of Mrs.Patel doing it she has an online program made for checks to do it for her.

6 0
3 years ago
Cascading style sheets (css) use special hypertext markup language (html) tags to globally define font characteristics for a var
ehidna [41]
The statement that Cascading style sheets (CSS) use special hypertext markup language (HTML) tags to globally define font characteristics for a variety of page elements as well as how those elements are laid out on a web page is true. <span> CSS is a stylesheet language used to describe the presentation of a document written in HTML or XML.</span>
5 0
3 years ago
Which option is used in emails to inform the recipient that they should exercise discretion in accordance with sharing the conte
Kay [80]
Priority levels hehe good luck!
5 0
3 years ago
Other questions:
  • Encryption relies on the use of _________to ensure that information is readable only by the intended recipient.
    5·1 answer
  • It is not recommended by the USA EPA, but adding refrigerant to a leaking A/C system is
    13·1 answer
  • What does FTP stand for?
    15·2 answers
  • I can create spreadsheets in Google Draw. False True
    14·2 answers
  • The top of a ladder must extend how many feet above the surface a worker is climbing onto?
    7·1 answer
  • Select the correct answer.
    8·2 answers
  • Write a C++ program that allows the user to enter double values. Display one of two messages: "The first number you entered is l
    9·1 answer
  • The __________ tag is used to create a forced line break without starting a new paragraph.
    13·1 answer
  • Supports traditional transactional processing for day-to-day front-office operations or systems that deal directly with the cust
    11·1 answer
  • I need help with this work
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!