Difference between revisions of "CPP/Loops/While"
From ProgrammingExamples
< CPP
FirstPerson (Talk | contribs) (Created page with '<source lang = "cpp"> #include <iostream> using namespace std; int main(){ const int END = 0; int input = -1; while(input != END){ cin >> input; cout << input * 2 << …') |
Daviddoria (Talk | contribs) |
||
(19 intermediate revisions by 14 users not shown) | |||
Line 1: | Line 1: | ||
− | <source lang = "cpp"> | + | <source lang="cpp"> |
#include <iostream> | #include <iostream> | ||
using namespace std; | using namespace std; | ||
− | + | ||
int main(){ | int main(){ | ||
− | + | ||
const int END = 0; | const int END = 0; | ||
int input = -1; | int input = -1; | ||
− | + | ||
while(input != END){ | while(input != END){ | ||
cin >> input; | cin >> input; | ||
cout << input * 2 << endl; | cout << input * 2 << endl; | ||
} | } | ||
− | + | ||
return 0; | return 0; | ||
} | } | ||
</source> | </source> |
Latest revision as of 11:12, 20 September 2011
#include <iostream> using namespace std; int main(){ const int END = 0; int input = -1; while(input != END){ cin >> input; cout << input * 2 << endl; } return 0; }