Question
Use only
Include<iostream>
Question 01: write a complete C++ program that should print the result of each of functions the following a. Function name: FindMinElement The function should take 3 integer values and returns the minimum the number. b. Function name: FindMaxElement The function should takes integer values and returns the maximum the number. C. Function name: FindAverage The function should ask the user to input double value for 10 times and it should returns the average Of those values. Function name: backtrackNum The function should take an integer number and print the backtrack of that number. Function name: FindDigitNumber The function should take an integer number and returns the total digit of that number. d. e.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question a:

Here is code:

int FindMinElement(int num1, int num2, int num3)

{

return (num1 < num2 && num1 < num3) ? num1 : (num2 < num3) ? num2 : num3;

}

Sample code to test:

#include <iostream>

using namespace std;

int FindMinElement(int num1, int num2, int num3)

{

return (num1 < num2 && num1 < num3) ? num1 : (num2 < num3) ? num2 : num3;

}

int main()

{

int num1, num2, num3;

cout << "Enter number #1 : ";

cin >> num1;

cout << "Enter number #2 : ";

cin >> num2;

cout << "Enter number #3 : ";

cin >> num3;

int result = FindMinElement(num1, num2, num3);

cout << "The largest number is : " << result << endl;

return 0;

}

Output:

Enter number #1 : 9 Enter number #2 : 5 Enter number #3 : 7 The largest number is 5

Question b:

Here is code:

int FindMaxElement(int num1, int num2, int num3)

{

return (num1 > num2 && num1 > num3) ? num1 : (num2 > num3) ? num2 : num3;

}

Sample code to test:

#include <iostream>

using namespace std;

int FindMaxElement(int num1, int num2, int num3)

{

return (num1 > num2 && num1 > num3) ? num1 : (num2 > num3) ? num2 : num3;

}

int main()

{

int num1, num2, num3;

cout << "Enter number #1 : ";

cin >> num1;

cout << "Enter number #2 : ";

cin >> num2;

cout << "Enter number #3 : ";

cin >> num3;

int result = FindMaxElement(num1, num2, num3);

cout << "The largest number is : " << result << endl;

return 0;

}

Output:

Question c:

Here is code:

double FindAverage()

{

double num, sum = 0;

for (int i = 0; i < 10; i++)

{

cout << "Enter number : ";

cin >> num;

sum += num;

}

return sum / 10;

}

Sample code to test:

#include <iostream>

using namespace std;

double FindAverage()

{

double num, sum = 0;

for (int i = 0; i < 10; i++)

{

cout << "Enter number : ";

cin >> num;

sum += num;

}

return sum / 10;

}

int main()

{

double avg = FindAverage();

cout << "\nAverage of numbers : " << avg;

}

Output:

Question d:

Here is code:

void backtrackNum()

{

int num;

cout << "Enter number : ";

cin >> num;

while (num != 0)

{

cout << num % 10 << " ";

num = num / 10;

}

}

Sample code to test:

#include <iostream>

using namespace std;

void backtrackNum()

{

int num;

cout << "Enter number : ";

cin >> num;

while (num != 0)

{

cout << num % 10 << " ";

num = num / 10;

}

}

int main()

{

backtrackNum();

}

Output:

Question e:

Here is code:

int FindDigitNumber()

{

int num, sum = 0;

cout << "Enter number : ";

cin >> num;

while (num != 0)

{

sum += num % 10;

num = num / 10;

}

return sum;

}

Sample code to tesT:

#include <iostream>

using namespace std;

int FindDigitNumber()

{

int num, sum = 0;

cout << "Enter number : ";

cin >> num;

while (num != 0)

{

sum += num % 10;

num = num / 10;

}

return sum;

}

int main()

{

int sum = FindDigitNumber();

cout << "The sum is : " << sum << endl;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Use only Include<iostream> Question 01: write a complete C++ program that should print the result of...
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
  • Write a program that asks the user to input a 4-digit integer and then prints the...

    Write a program that asks the user to input a 4-digit integer and then prints the integer in reverse. Your program needs to implement a function reverse that will take in as input the 4-digit number and print it out in reverse. Your code will consist of two files: main.s and reverse.s. Main.s will ask for the user input number and call the function reverse. For ARM/Data Structure needs to be able to run on Pi Reverse.s will take in...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • Write a complete C++ program that will: Declare a vector of integers Use a pointer to...

    Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...

  • Write a java program that will print if n numbers that the user will input are...

    Write a java program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times asking for an integer...

  • // demonstrates separating digits with a remainder operator // Mikhail Nesterenko // 01/22/2016 #include <iostream> using...

    // demonstrates separating digits with a remainder operator // Mikhail Nesterenko // 01/22/2016 #include <iostream> using std::cin; using std::cout; using std::endl; int main(){ cout << "Input number from 01 to 50: "; int number; cin >> number; const int singles = number % 10; const int tens = number / 10; cout << "tens: " << tens << endl; cout << "singles: " << singles << endl; You may assume that the user never inputs a number less than 1...

  • Write a program which will take a list of integer number from the user as input...

    Write a program which will take a list of integer number from the user as input and find the maximum and minimum number from the list. First, ask the user for the size of the array and then populate the array. Create a user define function for finding the minimum and maximum numbers. You have to use pointer variables for solving the problem. Finally, you need to print the entire list along with the max and min numbers ALSO NEED:...

  • question 2 in C programming please PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user...

    question 2 in C programming please PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_Student...

    Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_StudentlD where StudentID is your actual student ID number) that has one integer input (N) and one double input (x) and returns a double output S, where N S = n 0 and X2 is given by 0 xeVn n 0,1 Хл —{2. nx 2 n 2 2 m2 x2 3 (Note: in the actual quiz, do not expect a always, practice...

  • Question: In C++ Write a correct and complete C++ program th... Bookmark In C++ Write a...

    Question: In C++ Write a correct and complete C++ program th... Bookmark In C++ Write a correct and complete C++ program that inputs 20 integer values from the user and performs three calculations. In the main function, input the values from the user. As part of your answer, write a sub-function, named calcAvg (), which takes two arguments and returns the average of all the integers. Also write another sub-function, named reverseArray (), which takes two arguments and reverses the...

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