| | |
How do you for loop into a while loop??
![]() |
0
#2 Dec 2nd, 2009
The condition in the while loop will be the same as the for loop, namely the count is less than 51. Then just display the current count, and then increment the count variable by one.
This snippet (which I wrote in c++) displays what I just said,
Both loops do the same thing. I think thats what you are looking for.
This snippet (which I wrote in c++) displays what I just said,
int count=1;
for(count; count<51; count++)
cout<<" "<<count;
while(count<51)
{
cout<<" "<<count;
count++;
} Check out my new band Apollo's Soundtrack on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
•
•
Join Date: Sep 2008
Posts: 2,228
Reputation:
Solved Threads: 275
0
#3 Dec 3rd, 2009
int count = 1;
while count < 51{
display count;
count = count + 1;
} Last edited by Nick Evan; Dec 4th, 2009 at 3:21 am. Reason: Added code-tags
0
#4 Dec 4th, 2009
•
•
•
•
How do you for loop into a while loop??
But on a serious note (in C++ for example):
c++ Syntax (Toggle Plain Text)
int outer = 0; while (outer < 10){ for (int inner = 0; inner < 10; ++inner){ cout << "outer: " << outer << " inner: " << inner << '\n'; } outer++; }
Last edited by Nick Evan; Dec 4th, 2009 at 4:19 am.
![]() |
Similar Threads
- loop within a loop (Java)
- Make a for loop, loop until eof (C++)
- Could you tell me what about the difference between While..loop, for..loop ... (Pascal and Delphi)
- My loop won't loop in coin simulation! (C++)
- Loop...without the loop (Java)
Other Threads in the Computer Science Forum
- Previous Thread: Wallpaper Swapping Program
- Next Thread: CS Degree - Need Help Choosing Foreign Language
Views: 764 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
access ai algorithm algorithms architecture array assignment assignmenthelp assignments automata big-oh binary bizarre bootloader bubble business cern cheating-failed code codebreaker computer computers control conversion copyright data database development dfa dissertation dissertations dissertationthesis dissertationtopic education email execution extensions git github givemetehcodez government graphics gui guidelines homework homeworkassignment homeworkhelp idea ideas impress info information itcontracts jobs lazy lighthouse lincence math merge method mining mobile-apps mobileapplication ms news notation offtopic os parser problem programming project ps3 rasterizer recursion sam-being-cute science security selection servermonitoring sex simulation skills software sorting spoonfeeding sql sql-server student syntactic time tracking traffic tree turing uk university visualbasic warehouse writer






