Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Forum » x-Forum » Question

Converting for loop to while loop-CppBuzz-Forum

Hi, could someone help me convert this for loop to while loop
And how to detect how many times each one is executed or evaluated please?
Thank you


int x=1, a=33;
for(a=17; a< 20; a++){
	x++;
}

******************************

int x=1, a=33;

while(          ){

	x++;

}

Final value of a:______ 
Final value of x:______ 
How many times a=17 is executed :______
How many times a< 20 is evaluated:_______
How many times x++   is executed:________
How many times a++ is executed:_________

Posted by HelaMardiro 2021-02-05 11:55:44

int x=1, a=33;
a=17;
while(a++<20){
    x++;
}

//Please note to change x=1 to x=0 to print correct count of execution.

C++ user image Admin posted 2021-02-05 12:02:06

thank you for your reply. And how i can count for example how many times a=17 is executed. Or a<20 evaluated. :)

C++ user image HelaMardiro posted 2021-02-05 12:13:15

Please login to comment

Log In


Ask New Question