Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,233 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,713 people online right now. Registration is fast and FREE... Join Now!




program to print larger interger

 
Reply to this topicStart new topic

program to print larger interger

l_starter_l
12 Mar, 2007 - 05:57 PM
Post #1

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 2


My Contributions
include <iostream.h>

main ()
{
int x;
int y;
cout<<"enter 2 intergers"<<endl;
cin>>x;cin>>y;
if (x<y) cout<<x<<endl;
else cout<<y;
return 0;
}

this program is suppose to Write a program to input two integers and print out the larger one.
b. Modify the program in part a. so that the user can repeat it as long as they like. Have them enter Y if they want to do it again.

Im not sure how to do the y/n loop and it doesnt print the larger interger
can someone help
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Program To Print Larger Interger
12 Mar, 2007 - 06:25 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
CODE

if (x>y) cout<<x<<endl;
else cout<<y;

As for the loop, something like the following should work:
CODE

char input = 'Y';
while(input=='Y'){
   //your user prompt, comparison and display code
   cout<<"Enter Y to continue, or N to end:"<<endl;
   cin>>input;
}

User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 03:51PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month