<html><DIV>
<P>hello Scone, if your x is gonna be smaller then 100, then your output will be exactly 20 values.. so why would you want to pause it anyways? work on your formatting, its very poor :) i tried it with x being 200 and it worked... here is the program: </P>
<P>#include <iostream><BR>#include <stdlib.h></P>
<P><BR>int fPrintX(unsigned x, int& y)<BR>{<BR> cout << "x: " << x << " x^2: " << x*x << endl;<BR> y++;<BR> if (y == 20) // change the 20 with any number you want to pause it to<BR> {<BR> cout << x << " is the " << y << "th number\n";<BR> system("PAUSE");<BR> }<BR>} </P>
<P>int main() <BR>{ <BR> unsigned x;<BR> int y;<BR> x = y = 0;</P>
<P> cout << "This program will search all numbers smaller than 100 that" << endl;<BR> cout << "contain the number 2, and will also calculate the square." <<endl;</P>
<P> while (x<=200)<BR> {<BR> if (x%10==2)<BR> {<BR> fPrintX(x, y);<BR> }<BR> else if (x/10==2)<BR> {<BR> fPrintX(x, y);<BR> }<BR> x++;<BR> } </P>
<P> system("PAUSE");<BR> return 0;<BR>}<BR><BR></P>
<P>email me back.. if you want more explanation of this program..</P>
<P>good luck!</P>
<P>mpatel</P>
<P> </P>
<P> </P></DIV>
<DIV></DIV>
<DIV></DIV>>From: "Scone Scone" <SC...@HO...>
<DIV></DIV>>Reply-To: dev...@li...
<DIV></DIV>>To: dev...@li...
<DIV></DIV>>Subject: [Dev-C++] Stop system
<DIV></DIV>>Date: Thu, 21 Dec 2000 15:21:41 +0100
<DIV></DIV>>
<DIV></DIV>>Hello,
<DIV></DIV>>
<DIV></DIV>>I'm a beginning C++ programmer and I have made a program that
<DIV></DIV>>calculates all numbers smaller than 100 that contain a 2.
<DIV></DIV>>It seems to work, but I would like to be able to pause the output
<DIV></DIV>>when I have got e.g. 20 numbers, and when I press enter the program
<DIV></DIV>>should continue.
<DIV></DIV>>
<DIV></DIV>>So far I have this:
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM>
<DIV></DIV>>
<DIV></DIV>>int fPrintX(unsigned x)
<DIV></DIV>>{ cout << x << endl << x*x << endl;
<DIV></DIV>> y++;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> unsigned x, y;
<DIV></DIV>> y=0;
<DIV></DIV>> cout << "This program will search all numbers smaller than 100
<DIV></DIV>>that" <<
<DIV></DIV>>endl;
<DIV></DIV>> cout << "contain the number 2, and will also calculate the
<DIV></DIV>>square." <<
<DIV></DIV>>endl;
<DIV></DIV>> x=0;
<DIV></DIV>> while (x<=100)
<DIV></DIV>> { if (x%10==2)
<DIV></DIV>> { fPrintX(x);
<DIV></DIV>> }
<DIV></DIV>> else if (x/10==2)
<DIV></DIV>> { fPrintX(x);
<DIV></DIV>> }
<DIV></DIV>> if (y==20)
<DIV></DIV>> { //here I would like the program to pause
<DIV></DIV>> }
<DIV></DIV>> x++;
<DIV></DIV>> }
<DIV></DIV>> cin >> x;
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Thanks!
<DIV></DIV>>_________________________________________________________________________
<DIV></DIV>>Get Your Private, Free E-mail from MSN Hotmail at
<DIV></DIV>>http://www.hotmail.com.
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
<DIV></DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html>
|