-->

Write a program to get given pattern

/*WAP to get following
                                  * * * * * 
                        * * * * *
                   * * * * * 
             * * * * *
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=8;k>=i;k--)
      {
      printf(" ");   // this part is for space. every time , on display, it decreases space.
      }
    for(j=1;j<=4;j++) //it displays star five times.It displays in columns
      {
 printf("* ");
      }
    printf("\n"););
}
getch();
}
---------------------------
logic in mind:-
----------
it has three parts:
first is number of rows
second part is number of columns
third part decreasing space on each display.
1)fist loop is used for number of rows
2) the inner loop is for space to display
3)the inner most is for star display every time.

Program's screen:-


program's output:


Note:-
From here onward, we are writing program using return and int main().
so using return, it looks like.
#include <stdio.h>
#include<conio.h>
int main()
{
  int i,j,k;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=8;k>=i;k--)
      {
      printf(" ");   // this part is for space. every time , on display, it decreases space.
      }
    for(j=1;j<=4;j++) //it displays star five times.It displays in columns
      {
 printf("* ");
      }
    printf("\n");
}
   getch();
  return 0;
}
---------------------------------------------------
read me:-

nothing you have to do here. Just put int main() in the beginning and return 0 at the end

wap to display star pattern

/*program to display following

* * * * *
    * * * * *
* * * * *
         * * * * *
             * * * * *

*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k;
for(i=5;i>=1;i--)      //for number of rows. there are five rows so loop moves fives times
  {
    for(k=i;k<=7;k++)
      {
      printf(" ");   // this part is for space. every time , on display, it increases space.
      }
    for(j=1;j<=5;j++) //it displays star five times.It displays in columns
      {
printf("* ");
      }
    printf("\n");
}
getch();
}
---------------------------
logic in mind:-
----------
it has three parts:
first is number of rows
second part is number of columns
third part increasing space on each display.
1)fist loop is used for number of rows
2) the inner loop is for space to display
3)the inner most is for star display everytime.
------------------------------------------------------
program screenshot


output is






WEAP to display following star pattern

/*program to display following

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=5;i++)      //for number of rows. there are five rows so loop moves fives times
  {
    for(j=1;j<=5;j++) //it displays star five times.It displays in columns
      {
printf("* ");
      }
    printf("\n");
}
getch();
}

------------------------------------
logic in mind:-
1)we have to display five rows and five columns.
2) we have used outer loop five times.
3)and inner loop five times.
-------------------------------
 program 's screenshot





output







write a program to display plus pattern

/*to display following
  +
               +
               +
               +
   + + + + + + + + +
              +
              +
              +
              +
              +
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='+';
int i,j,k=0,k1;
for(i=4;i>=0;i--)
{
  for(k1=-3;k1<=5;k1++)
     {
       printf(" ");
     }
  for(j=1;j<=1;j++)
    {
      printf("%c",a);
    }
  printf("\n");
}
for(i=1;i<=9;i++)
{
for(k1=5;k1<=5;k1++)
     {
       printf(" ");
     }
printf("+");
}
for(i=4;i>=0;i--)
{
  for(k1=-3;k1<=5;k1++)
     {
       printf(" ");
     }
  for(j=1;j<=1;j++)
    {
      printf("%c",a);
    }
  printf("\n");
}
getch();

}
-------------------
logic in mind:-
1)for this display, we have three parts.
      first part is upper 
      second part is horizontal
      third part is vertical form(look circled part)
2) First we display upper part using three loops.
          outer loop is for number of rows
           inner is for space(constant)
          inner most is for display
3) similarly, for second part we have done. ----------------------
program's screenshot:-

----------------------------
program's output:-

WAP to get following alphabetical pattern

/*WAP to get following

ABCDE
ABCD
ABC
AB
A
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=4;i>=0;i--)
{
  for(j=0;j<=i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-----------------
logic in mind
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so. 
for more: look down.
--------------
program screenshot:-



program output:-


to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");
  //a++;
}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-