+ 3

Explain the using a while loop.

guys I am not able to understand while loop so, please explain me in simple way.

17th Oct 2018, 2:57 PM
srijan gupta
srijan gupta - avatar
2 Respuestas
+ 3
while () { //body of loop } it is a common syntax of while loop if you want pergmform any operation in multiple times so you can use while loop suppose you want print 0 to 10 numbers, I so you will write while loop like that int a=0; while (a<=10) { a++; printf ("%d",a); } and the output is 0 1 2 3 4 5 6 7 8 9 10
17th Oct 2018, 3:11 PM
Harinarayan Sahu
Harinarayan Sahu - avatar
+ 1
syntax of while loop is: while(condition) { //operations //output statements //increment or decrement statements } it performs operation many times and print output of each operation still the condition becomes false. example- int count= 1; while (count < 8) { printf("Count = %d\n",count); //output statement count++;//increment statement } return 0; } output: count=1 count=2 cont=3 count=4 count=5 count=6 count=7
27th Oct 2018, 6:49 AM
Kingsman