I was trying to solve the Pattern1 problem, in which i declared rows and columns initially like:
but this prints the stars for one row only. Why? If i do by declaring int cols =0; inside the rows loop it works why?
I was trying to solve the Pattern1 problem, in which i declared rows and columns initially like:
but this prints the stars for one row only. Why? If i do by declaring int cols =0; inside the rows loop it works why?
@mananmodi.0108,
If you declare it inside the loop, it will reset everytime the while loop runs.
if its outside, once it reaches cols = n. It will not reset. Hence it prints only 1 row.