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
The information of an management information system comes from?
Debora [2.8K]

A management information system is a computer system consisting of hardware and software that serves as the backbone of an organization's operations

5 0
2 years ago
What is one current method of detecting planets orbiting around other stars?
Gnoma [55]
C

D is the old way.

A they have not done yet

B not even a thing
5 0
3 years ago
2.13.4 Colorful Caterpillarhel ????
exis [7]

Answer:

sorry don't know :(8685

3 0
2 years ago
It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating syst
Vikki [24]

Answer:

Here the code is given as follows,

Explanation:

7 0
2 years ago
Write a Java program that reads two numbers from the console. Based on the example in the textbook, write five methods (min, max
makvit [3.9K]

Answer:

import java.util.Scanner;

public class num6 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter first number");

       int a = in.nextInt();

       System.out.println("Enter second number");

       int b = in.nextInt();

       //Calling the methods inside the output statement

       System.out.println("Min is "+min(a,b));

       System.out.println("Max is "+ max(a,b));

       System.out.println("Sum is "+sum(a,b));

       System.out.println("Product is "+product(a,b));

       System.out.println("Absolute difference is "+difference(a,b));

   }

   //Min Method

   static int min(int a, int b){

       if (a<b){

           return a;

       }

       else {

           return b;

       }

   }

   //Max Method

   static int max(int a, int b){

       if (a>b){

           return a;

       }

       else {

           return b;

       }

   }

   //Sum Method

   static int sum(int a, int b){

       return a+b;

   }

   //Diference Method

   static int difference(int a, int b){

       int diff = Math.abs(a-b);

       return diff;

   }

   //Product Method

   static int product(int a, int b){

       int prod = a*b;

       return prod;

   }

}

Explanation:

  • Using Java programming language
  • Use the scanner class to prompt and receive two values from the user (integers a and b)
  • Create the four methods as required (Please see the comments in the code)
  • In the difference method use Math.abs() to get the absolute value of the subtraction ensuring that you get a positive number returned
4 0
2 years ago
Read 2 more answers
Other questions:
  • How many times do you usually use npm?<br> Put your answer in the box.
    6·1 answer
  • Meg is in the process of creating a storyboard for her personal website, but she is unable to decide which storyboarding techniq
    10·1 answer
  • Write a Temperature class that will hold a temperature in Fahrenheit, and will provide methods to get and display the temperatur
    5·1 answer
  • What are the functions of online gaming communities?
    12·1 answer
  • Which of the following is the fastest way to open an Access database? a. Right-click the database icon. b. Start Access from the
    13·2 answers
  • What internal hardware device does a computer use to connect to a wired or a wireless network?
    10·1 answer
  • What would be a good hash code for a vehicle identification that is a string of numbers and letters of the form “9x9xx99x9xx9999
    9·1 answer
  • Using ________ as a promotion method will bring return visitors to your site.
    8·1 answer
  • Consider a disk that rotates at 3600 rpm. The seek time to move the head between adjacent tracks is 2 ms. There are 32 sectors p
    5·1 answer
  • Before you ever buy your first stock or bond, it's important to understand what type of investor you are. This depends on a numb
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!