This pattern is done with another
interesting logic. A very simple logic is there behind this program.
The pattern looks like it is started with
11 but loop are initialize with 1 only so what is the logic behind such pattern
Here there is no change in loop but printf
statement is changed.
As you can see loops are same as that of
the first program of ‘*’.
But printf statement changes: as we want to
print 11 first i.e. starting from 11 so
Printf(“%d”, 9+i+j)
In printf statement we add 9 with
respective values of i and j in loops. When loop executes for the first time i
and j both will be 1 so we get (9+1+1=11), the second time i increments so
(9+2+1=12), then i remains same and j increments so (9+2+2=13), then again i
increments so (9+3+1=13) and so on. Thus how loop works here.
{ 0 comments ... read them below or add one }
Post a Comment