| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ok im obviosly new to c++ and have sucessfuly made the famous
Hello world! program. but i am haveing troble with my next program P.S i am using http://www.cplusplus.com/doc/tutorial/index.html tutorials the program is suposed to count down from any enterd number but when i hit enter the program terminates whats wrong //custom countdown using while #include <iostream.h> int main () { int n; cout << "enter the starting number"; cin >> n; while (n>0) { cout << n << ", "; --n; } cout << "FIRE!"; return 0; } any help would be great |
|
#2
|
|||
|
|||
|
Might be because console application closes at once after it's done it's work, try this one
#include <iostream.h> #include <windows.h> #include <stdio.h> int main () { int n; printf("enter the starting number"); cin >> n; while (n>0) { printf("%i, ",n--); } printf("FIRE!\n"); system("pause"); return 0; } practically the same, just using printf for displaying. |
|
#3
|
|||
|
|||
|
thx that worked
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > newb qestion about c++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|