+ 1

Write repeat-until equivalent using while loop.

repeat-until execute the statements inside the loop till the condition is false. whereas while loop executes the statements inside loop till the condition is true. I need repeat-until equivalent of while loop with appropriate example. Thanks, SagaTheGreat💯

23rd Jun 2018, 5:52 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
2 Respuestas
+ 5
pass the condition with a negation while ( !(condition)) this will execute the block until the condition is false. example: i= 0 while( !(i==5)) // run until i isn't equal to 5 { cout<<i; i++; } output: 01234
23rd Jun 2018, 6:05 PM
Nikhil Dhama
Nikhil Dhama - avatar
+ 1
In python myVar = 0 while True : myVar += 1 if myVar == 5 : print 'myVar is '+str(myVar) break else: print 'printing "else" block' in c++ #include <iostream> using namespace std; int main() { int myVar = 0; while(true) { if(myVar ==5){ cout<<myVar; break; } else{ cout<<"printing else block \n"; } myVar++; } }
23rd Jun 2018, 6:56 PM
ᴋᵘⁿᵃˡ
ᴋᵘⁿᵃˡ - avatar