Question

(write algorithm and draw flowchart) for this question Write a C program which has a function...

(write algorithm and draw flowchart) for this question

Write a C program which has a function that takes two numbers and find the largest and the smallest number and find the result of the largest power of smallest.(for example If the entered numbers are 6 and 3 the result is 6³)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>

int main()
{
int first, second;
double power;
//Take user input
   printf("Enter first number: ");
   scanf("%d",&first);
   printf("Enter second number: ");
   scanf("%d",&second);
  
   //Check if both the numbers are same
   //else check if first one is larger and find power Largest to smallest
   //else second is larger and find power Largest to smallest
   if(first==second)
   {
   printf("Both numbers are same");
   }
   else if(first>second)
   {
   printf("Largest number is: %d",first);
   power = pow(first,second);
   printf("\nLargest power of smallest: %.0lf",power);
   }
   else
   {
   printf("Largest number is: %d",second);
   power = pow(second,first);
   printf("\nLargest power of smallest: %.0lf",power);
   }
  

return 0;
}
Output:

Algorithm:

1) Declare variables to hold both numbers
2) Check whether both numbers are the same.
3) Check if the first number is greater, if yes then calculate pow of the first number to the second number.
4) Check if the second number is greater, if yes then calculate pow of the second number to the first number.

Flowchart:

Add a comment
Know the answer?
Add Answer to:
(write algorithm and draw flowchart) for this question Write a C program which has a function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q4. Write an algorithm, draw the flowchart and write a C++ program to • Read the...

    Q4. Write an algorithm, draw the flowchart and write a C++ program to • Read the Number and Letter from the user • Check the number and letter then print the corresponding month name as given in Table Q4 using IF ELSE STATEMENT. Table: Q4 Number and Letter Month Name JANUARY 2 F FEBRAURY 3 M MARCH 4 A APRIL Other numbers Invalid Input 1J Sample Output: Enter the value of number:1 Enter the value of letter:) JANUARY Algorithm: Flowchart:...

  • Example 3: Draw a flowchart that performs the following: Ask a user to enter a number....

    Example 3: Draw a flowchart that performs the following: Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red. if the number is between 20 and 30, write the word green. If it is any other number, write that it is not a correct color option. Example 4: Draw a flowchart to print all multiples of 5 between 1...

  • Flowchart Question 1. Draw a flowchart to read five numbers and print the second maximum 2....

    Flowchart Question 1. Draw a flowchart to read five numbers and print the second maximum 2. Draw a flowchart to read five numbers and then order them from smallest number to largest number. 3. Draw a flowchart to read five numbers and then order thenm from smallest number to largest number and display the second maximum.

  • Flowchart Question 1. Draw a flowchart to read five numbers and print the second maximum 2....

    Flowchart Question 1. Draw a flowchart to read five numbers and print the second maximum 2. Draw a flowchart to read five numbers and then order them from smallest number to largest number. 3. Draw a flowchart to read five numbers and then order thenm from smallest number to largest number and display the second maximum.

  • ​ Draw a flowchart

     Draw a flowchart that will perform the following.a) Read in 5 separate numbers.b) Calculate the average of the five numbers.c) Find the smallest (minimum) and largest (maximum) of the five entered numbers.d) Write out the results found from steps b and c with a message describing what they are

  • Q1: Write an algorithm and sketch the flowchart to read 20 numbers for x and finding...

    Q1: Write an algorithm and sketch the flowchart to read 20 numbers for x and finding the number of times that the number 100 is repeated between these numbers. (12 marks) Q2: What is the difference between prefix decrementer (- - i) and postfix decrementer (i - -) explain using examples. Q3: C++ includes a very special operator called the ternary operator. Explain with example how this operator used? Q4: Write C++ Program which output this result ******50 *****500 ****5000...

  • For each question, you are required to draw a flowchart diagram and a C++ program. For...

    For each question, you are required to draw a flowchart diagram and a C++ program. For flow charts you are required to use a Computer Aided Software Engineering (CASE) tool for example Dia (Download from http://diainstaller.de/). a. Write a program that prints the first 107 prime numbers. b. Write a program that determines whether a number given by the user is a leap year or not. Please write a program in c++.. Thank you and add the comments for the...

  • (Do algorithm and flowchart) Q1 Write 2 functions: int reverse (int) which returns reverse of a...

    (Do algorithm and flowchart) Q1 Write 2 functions: int reverse (int) which returns reverse of a number and int diff(int, int) which returns difference of two numbers. Using this Write a program to find whether a number given as input is palindrome or not

  • 6. Write a program (compile and run), a pseudocode, and draw a flowchart for each of...

    6. Write a program (compile and run), a pseudocode, and draw a flowchart for each of the following problems: a) Obtain three numbers from the keyboard, compute their product and display the result. b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers. c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the user types the...

  • 3. (c-program) Write a program that finds the largest and smallest value in a series of...

    3. (c-program) Write a program that finds the largest and smallest value in a series of numbers entered by a user. The user must enter 25 values. Note if that if the user enters "0" they must correct and add another number. Print out the original entered values, the largest number, the smallest number. Note whether the user tried to enter "O".

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT