0

Explain the code

#include<stdio.h> int main() {int i=1,j=1; while(i++<=100) {while(j++<=200) {if(j==150) break; else printf("%d%d\n",i,j);}} return(0);}

6th Dec 2018, 3:56 AM
Rutuja Pawar
Rutuja Pawar - avatar
2 Answers
+ 15
#include<stdio.h> int main(){ int i=1,j=1; while(i++<=100){ while(j++<=200){ //● for i=2, j will print from 2 to 149 & then break;(bcz of j=150)) ... so will come out of inner loop & then after coming to outer loop i becomes 3 //● for i=3 & j prints from 151 to 201 //● now since j=201, inner loop will not work(as 201 is Not <=200) for any value of i, so operation stops. if(j==150) break; else printf("%d %d\n",i,j); //● putten space between i & j to notice output clearly } } return(0); }
6th Dec 2018, 4:08 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
Hi cool
6th Dec 2018, 5:26 AM
Samson
Samson - avatar