Write a C++ program that takes two integer outputs the first input when the first int outputs the second integer when the se integer Edit View Insert Format Tools Table 12pt Paragraph BIU
Write a C++ program that takes two integer outputs the first input when the first int outputs the second integer when the se integer Edit View Insert Format Tools Table 12pt Paragraph BIU
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

Transcribed Image Text:### C++ Program Task
Create a C++ program that takes two integer inputs and performs the following:
- Outputs the first input when the first integer is greater than or equal to the second integer.
- Outputs the second integer when the second integer is greater than but not equal to the first integer.
This task encourages students to explore conditional statements and logical operations fundamental to programming in C++.
Expert Solution

Step 1
Program Approach:
- Step 1: Include the standard library for i/o operations.
- Step 2: Create the greatest(int a, int b) function that takes two parameters a and b, and returns the greatest between the two.
- Step 3: Inside the greatest(int a, int b) function, check whether a is greater than or equal to b.
- Step 4: If the condition is valid then return a, otherwise, return b.
- Step 5: Create the main() method.
- Step 6: Inside the main() method, declare two integer variables n1 and n2.
- Step 7: Take the first number from the user and store it in variable n1.
- Step 8: Take the second number from the user and store it in variable n2.
- Step 9: Display the greatest number between n1 and n2 by calling the function greatest(n1,n2).
Step by step
Solved in 3 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education