Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
### 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++.
expand button
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
Check Mark
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).
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education