for count= 1 to 50
display count
End for

Recommended Answers

All 5 Replies

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,

int count=1;
    for(count; count<51; count++)
    cout<<" "<<count;
    
    while(count<51)
    {
      cout<<" "<<count;
      count++;
    }

Both loops do the same thing. I think thats what you are looking for.

for count= 1 to 50
display count
End for

int count = 1;
while count < 51{
    display count;
    count = count + 1;
}
How do you for loop into a while loop??


But on a serious note (in C++ for example):

int outer = 0;
while (outer  < 10){
    for (int inner = 0; inner < 10; ++inner){
        cout << "outer: " << outer << " inner: " << inner << '\n';
    }
    outer++;
}

Umm I might be confused but I just got three PMs from you (posted above me) and you just reiterated what two previous posters in here have already said. Was that really necessary?

Umm I might be confused but I just got three PMs from you (posted above me)

From me? I didn't send you anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.