USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF FORWARD ARROW

September 22, 2018




                  Hello, In this blog we learn how to print the forward pattern using for loop. In C language the for loop is very useful, for loop include initialization, condition and incrementation. So by using this loop we print the pattern.

USING FOR LOOP THE CODE TO DISPLAY THE PATTERN:

#include<stdio.h>
#include<conio.h>
int main()
{int i, j, n;
printf ("ENTER THE NUMBER TO DISPLAY PATTERN ");
scanf ("%d",&n);
for(i=1; i<=n; i++)
{for(j=1; j<=i; j++)
{printf("♥ ");
}
printf("\n");
}
{ for(i=1; i<=n; i++)
{for(j=i; j<n; j++)
{printf("♥ ");
}
printf("\n");
}}
getch();
}

EXPLANATION:
             By using the concept of for loop we print the pattern. First we set the initial value of  'i'  i.e. i=1. then it checks the condition i.e. i<=n, n is the value given by the user. then control goes to next statement i.e. in next for loop and we set the initial value of j=1 and check the condition and print ♥.
The execution goes out of the loop when the condition returns false. \n is use to print the statement at next line. So below we see the output of the given code.
             Also, we create other pattern using for loop, while loop or using if statement.

OUTPUT:
When inputted is 5
♥
♥ ♥
♥ ♥ ♥
♥ ♥ ♥ ♥
♥ ♥ ♥ ♥ ♥
♥ ♥ ♥ ♥
♥ ♥ ♥
♥ ♥
♥
                   In this code I'm using the ♥ sign you will use any sign. If you have any problem or question about this blog then write your doubt in the comment box.
                   Friends in next blog I will teach you another patterns.




USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF FORWARD ARROW USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF FORWARD ARROW Reviewed by Amit Waghmare on September 22, 2018 Rating: 5

USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF DOWNWARD HALF PYRAMID

September 22, 2018


USING FOR LOOP THE CODE TO DISPLAY THE PATTERN:

#include<stdio.h>
#include<conio.h>
int main()
{int i, j, n;
printf ("ENTER THE NUMBER TO DISPLAY PATTERN ");
scanf ("%d",&n);
for(i=1; i<=n; i++)
{for(j=i; j<=n; j++)
{printf("♥ ");
}
printf("\n");
}
getch();
}

OUTPUT:
When inputted is 5
♥ ♥ ♥ ♥ ♥
♥ ♥ ♥ ♥
♥ ♥ ♥
♥ ♥
♥
In this code I'm using the ♥ sign you will use any sign. If you have any difficulty the write in the comment box. Friends in the next blog I will teach different patterns.




USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF DOWNWARD HALF PYRAMID USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF DOWNWARD HALF PYRAMID Reviewed by Amit Waghmare on September 22, 2018 Rating: 5

USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF HALF PYRAMID

September 22, 2018


USING FOR LOOP THE CODE TO DISPLAY THE PATTERN:

#include<stdio.h>
#include<conio.h>
int main()
{int i, j, n;
printf ("ENTER THE NUMBER TO DISPLAY PATTERN ");
scanf ("%d",&n);
for(i=1; i<=n; i++)
{for(j=1; j<=i; j++)
{printf("♥ ");
}
printf("\n");
}
getch();
}

OUTPUT:
When inputted is 5
♥
♥ ♥
♥ ♥ ♥
♥ ♥ ♥ ♥
♥ ♥ ♥ ♥ ♥

In this code I'm using the ♥ sign you will use any sign. If you have any difficulty the write in the comment box. If you want all explanation of this code then type your comment, I will give you.




USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF HALF PYRAMID USING FOR LOOP THE CODE TO DISPLAY THE PATTERN OF HALF PYRAMID Reviewed by Amit Waghmare on September 22, 2018 Rating: 5

Introduction of loops in c language

September 22, 2018

                          Friends in c there are different types of loop statements like for loop, while loop, do-while loop, etc. and in this blog, I will explain the for loop, while loop and do-while loop.
●for loop:
                          for loop is entry controlled loop. When loop value returns true then the body of the loop executed till the value returns true, if loop value returns false controlled transfer to end of the program and the body will not be executed.

Syntax.
for(initialization; condition; incrementation)
{ body of the loop
}

●while loop:
                      This is the entry control loop or talk tested looping statement. This loop test the condition first if the condition returns true then the body of the loop is executed till the loop value returns true if the condition value returns false then the control is transfer to the out of the loop and body of the loop does not execute.

Syntax.
while (test the condition)
{
Body of the loop;
}

●do-while loop:
                     This is called as exit control or button tested looping statement. In this loop, the body of the loop executed first the condition will be check. If the condition returns true then the body of the loop executed continuously till the condition value returns true if condition value returns false then also the body of the loop is executed ones.

Syntax.
do
{
Body of the loop;
}
while (test the condition)

FRIENDS OUR LIFE IS LIKE A LOOP BECAUSE IN OUR LIFE MANY TURNS come AND ACCORDING TO THAT TURNS WE ARE MAKE A DECISIONS





Introduction of loops in c language Introduction of loops in c language Reviewed by Amit Waghmare on September 22, 2018 Rating: 5