Re: [Dev-C++] Newbie Question Using function getch() of library conio.h
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Oscar <osc...@wa...> - 2004-04-26 18:03:12
|
----- Original Message -----
From: "Jay Blanchard" <jay...@ni...>
To: "JTBaccarat" <jtb...@ro...>; "Dev-C++"
<dev...@li...>
Sent: Monday, April 26, 2004 7:01 PM
Subject: RE: [Dev-C++] Newbie Question
[snip]
#include <iostream>
using namespace std;
int main()
{ // EXAMPLE 3.8 USING COMPOUND CONDITIONS
// Uses the compound conditions to find the minimum of three integers
int n1,n2,n3;
cout << "Enter three integers: ";
cin >> n1 >> n2 >> n3;
if (n1 <= n2 && n1 <= n3) cout << "Their minimum is " << n1 << endl;
if (n2 <= n1 && n2 <= n3) cout << "Their minimum is " << n2 << endl;
if (n3 <= n1 && n3 <= n2) cout << "Their minimum is " << n3 << endl;
cin.get();
return 0;
}
[/snip]
Add this line before return 0;
system("PAUSE");
So....
#include <iostream>
using namespace std;
int main()
{ // EXAMPLE 3.8 USING COMPOUND CONDITIONS
// Uses the compound conditions to find the minimum of three integers
int n1,n2,n3;
cout << "Enter three integers: ";
cin >> n1 >> n2 >> n3;
if (n1 <= n2 && n1 <= n3) cout << "Their minimum is " << n1 << endl;
if (n2 <= n1 && n2 <= n3) cout << "Their minimum is " << n2 << endl;
if (n3 <= n1 && n3 <= n2) cout << "Their minimum is " << n3 << endl;
cin.get();
system("PAUSE");
return 0;
}
/************************************/
Other way:
#include <iostream>
#include <conio.h>
using namespace std; // <-- I don't understand, CAN YOU HELP ME? But de
program pause run correctlly
int main()
{ // EXAMPLE 3.8 USING COMPOUND CONDITIONS
// Uses the compound conditions to find the minimum of three integers
int n1,n2,n3;
cout << "Enter three integers: \n"; // "\n" is the endline endl; in c#
cin >> n1 >> n2 >> n3;
if (n1 <= n2 && n1 <= n3) cout << "\nTheir minimum is " << n1 << endl;
if (n2 <= n1 && n2 <= n3) cout << "\nTheir minimum is " << n2 << endl;
if (n3 <= n1 && n3 <= n2) cout << "\nTheir minimum is " << n3 << endl;
getch(); // <-- this is the other way using conio.h
return 0;
}
/*************************************/
-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg297
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|