What is pattern in C? | 1 2*3 4*5*6 pattern printing in c

 hi everyone welcome to coding idea

<image>

How do I print a pattern?

this is cinemas so in the
last session we discussed how to print
patterns using for loops now we will see
one more pattern alright for example now
we are we need to print this pattern so
1 star 2 starts 3 4 5 so now this
pattern we need to print this pattern
how to print this pattern see along with
this we have to print this one also this

is important for spaces one star three
spaces two stars two spaces one space
and zero space we need to print this so
how to print how many rows are present
so total fire rows are present I value
starts with 1 I is less than or equals
to 5 I plus plus I plus plus say in the
previous sessions so we discussed right

how to print some of the patterns so
what are the patterns once again we'll
see so because this pattern logic is
based on the discussed patterns see
suppose so these are the patterns we
discussed 1 star 2 starts 3 4 5 so this
is one pattern and next one five stars
four stars 3 2 1 this is one pattern

What is pattern printing?

already completed this is one pattern it
is also completed now based on these two
patterns now we can write the logic of
this pattern easily how see for example
here it is how many rows are there five
rows are there outer loop always
represents a number of rows so here it
is outer loop we are repeating from 1 to
5 5 times it will repeat once the

control move inside inside we have to
write a two loops so this is one four
loop so by using this four loop what we
will
- so we will print spaces printf space
we are printing and next using second
for loop we are printing starts we are

printing starts so first here it is how
many times we need to repeat this loop
nothing but how many spaces we need to
print one two three four and next one
here it is how many times we need to
print stars only one time we need to
print the star once these two for loops

execution completes then we should send
the control to next line printf / in
this is a skeleton now how to write the
initialization statements conditions and
modify here it is J value starts with
the so that we will see J is less than
or equals to and J plus plus take one
more variable K value starts with K is
less than or equals to k plus plus now

What is print and pattern?

what is the initial value and what is
the condition observe here one star we
are printing two stars three stars four
stars five stars so look at this one the
pattern we already completed one star
two stars three four five nothing but
this pattern logic this pattern logic
both are same so both are so whatever
the logic you have written for this

pattern the same logic you can copy here
nothing but stars printing how to write
so K value starts with a 1 K is less
than or equals to I initially I value is
a 1 so K value starts with a 1 1 is less
than or equals to 1 condition true first
time 1 star it prints in the next

iteration here it is a high value become
2 so from starts with 1 up to to 2 times
it will iterate so 2 stars it will print
next whenever I value 3 3 times it will
iterate 3 stars it will print so like
like that see printing the stars in the
first iteration one star in the second
iteration two stars in the third

iteration three stars four five so like
that it will print stars logic is over
now here it is we need to print a space
as logic how to pin the space is logic
look at this five stars four three two
one and look at this four three two one
zero

How to print pattern

see these two just looking like the same
this one and this one only difference is
here we are printing stars here we are
printing spaces so these two logics are
same this logic and this logic same okay
now this logic we are writing here here
so here it is we need to write this
logic so what is this logic here it is a
five stars four stars three two one here
it is I will use J value starts with the
I J is less than or equals to five first

J value starts with what is I value 1 so
1 is less than or equals to 5 total 5
times it will repeat 5 times so 5 stars
it will print next I value become 2 so
it starts with the 2 from 2 to 5 mins 2
3 4 5 only four iterations 4 stars it
will print

next I will you become three three four
five three iterations so three stars it
will print so like that but here it is
we are writing the logic of stars 5 4 3
2 1 but here it is a 4 3 2 1 0 right
just minus 1 or only just less than 5
this is enough less than 5 I value
starts with 1 1 is less than 5 means
what 1 2 3 4 so 4 iterations so 4 spaces

it will print this is logic so for
example same logic I just want to write
using all our decrement operators Here I
am using increment operators I plus plus
J plus

plus and K plus plus now I want to use
all our decrement operators how to write
the logic see so same logic so how we
can implement with the help of decrement
operators for example outer loop how
many rows are there fire rows are there
so same I value starts with a 5 is
greater than or equals to 1 I minus
minus I equals to 5 I is greater than or

equal to 1 I minus minus and here it is
in the second 1j value starts with and J
is greater than or equals to J minus
minus K value starts with K is greater
than or equal to K minus minus and what
is the initial value and what is the
condition that we'll see for example
here right this is the space logic and

this is the stores logic first I will
print that stars logic how many stars
one star two stars three stars four
stars five stars here it is first
I value starts with a 5 I value starts
with a 5 so here it is a k value starts
with a 5 K is greater than or equals to

rogram to print pyramid pattern of numbers

I this consider first K value 5 5 is
greater than or equal to I value 5 how
many times it will execute 5 is greater
than or equal to 5 condition true one
time so 1 star it will print next K
minus minus K value become 4 4 is
greater than or equals to 5 condition
true or false false then it terminates

so in the first row only one star it
prints next value I value is a 4 first I
value is a 5 next I value is a 4 in the
second iteration starts with a 5 up to 4
5 for two iterations so two times it
will repeat 2 stars it will print in the
second row
next I will you become 3 so here it is a
K value always starts with a 5 only but
here it is up

three so five four three three
iterations so three stars it will print
next I value become two next I value
become one so first it will print in the
third case in the fourth case for Phi 2
2 so nothing but 5 4 3 2 4 starts it
will print so like that it is printing
the Stars sir stars logic is okay now
spaces logic spaces how to print the
spaces first off I spaces four spaces

three spaces two spaces one space very
simple here it is J value starts with I
J is greater than or equals to 1 observe
first I value is a 5 so 5 2 1 5 4 3 2 1
5 times it will repeat so 5 spaces it
will print next I value become 4 so it
starts with the 4 4 3 2 1 4 spaces it
will print next I value become 3 3
spaces it will print 3 2 1 it prints
right sir here first time we are not
printing 5 spaces are only 4 space 4 3 2
1 0 simple instead of writing a greater

than or equals to simply we are writing
greater than 1 simple so here it is the
first starts with a 5 5 is greater than
1 greater than 1 means what 5 4 3 2 4
spaces only it will print next 2 3

What is pattern printing?

spaces 2 spaces one space and 0 spaces
selected ok so this is how to print this
pattern using increment operators in all
the 3 loops and using decrement
operators in all the 3 loops okay so
this is for some more patterns so we
will see in the coming sessions ok for
more articel

Post a Comment

0 Comments