PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Program Based on Pattern

SOURCE CODE

PROBLEM-1

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

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             printf("* ");
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             cout<<"* ";
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

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

PROBLEM-2

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

Code


#include <stdio.h>
int main()
{
      int num,col=1,a=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             printf("%d ",a);
             if(i<(num/2+1))
         {
               col++;
               a++;
         }
             else
         {
               col--;
               a--;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             cout<<a<<" ";
             if(i<(num/2+1))
         {
               col++;
               a++;
         }
             else
         {
               col--;
               a--;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

PROBLEM-3

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             printf("%d ",j);
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             cout<<j<<" ";
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

PROBLEM-4

A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=col;j++)
       {
             printf("%c ",ch);
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=col;j++)
       {
             cout<<ch<<" ";
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A

PROBLEM-5

1
1*2
1*2*3
1*2*3*4
1*2*3*4*5
1*2*3*4
1*2*3
1*2
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             if(j!=1)
             printf("*%d",j);
             else
             printf("%d",j);
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=col;j++)
             if(j!=1)
             cout<<"*"<<j;
             else
             cout<<j;
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1*2
1*2*3
1*2*3*4
1*2*3*4*5
1*2*3*4
1*2*3
1*2
1

PROBLEM-6

A
A*B
A*B*C
A*B*C*D
A*B*C*D*E
A*B*C*D
A*B*C
A*B
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=col;j++)
       {
             if(j!=1)
             printf("*%c",ch);
             else
             printf("%c",ch);
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=col;j++)
       {
             if(j!=1)
             cout<<"*"<<ch;
             else
             cout<<ch;
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A*B
A*B*C
A*B*C*D
A*B*C*D*E
A*B*C*D
A*B*C
A*B
A

PROBLEM-7

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

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             printf("* ");
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             cout<<"* ";
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

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

PROBLEM-8

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             printf("%d ",j);
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             cout<<j<<" ";
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1

PROBLEM-9

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
A B C D E F G
A B C D E
A B C
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=2*col-1;j++)
       {
             printf("%c ",ch);
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=2*col-1;j++)
       {
             cout<<ch<<" ";
             ch++;
       }
          if(i<(num/2+1))
             col++;
          else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
A B C D E F G
A B C D E
A B C
A

PROBLEM-10

1
1*2*3
1*2*3*4*5
1*2*3*4*5*6*7
1*2*3*4*5*6*7*8*9
1*2*3*4*5*6*7
1*2*3*4*5
1*2*3
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             if(j!=1)
             printf("*%d",j);
             else
             printf("%d",j);
             if(i<(num/2+1))
             col++;
             else
             col--;
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=2*col-1;j++)
             if(j!=1)
             cout<<"*"<<j;
             else
             cout<<j;
             if(i<(num/2+1))
             col++;
             else
             col--;
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1*2*3
1*2*3*4*5
1*2*3*4*5*6*7
1*2*3*4*5*6*7*8*9
1*2*3*4*5*6*7
1*2*3*4*5
1*2*3
1

PROBLEM-11

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

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf(" ");
         for(int k=1;k<=col;k++)
             printf("* ");
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             cout<<" ";
         for(int k=1;k<=col;k++)
             cout<<"* ";
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

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

PROBLEM-12

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

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
             printf("* ");
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             cout<<"  ";    /* double space */
         for(int k=1;k<=2*col-1;k++)
             cout<<"* ";
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

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

PROBLEM-13

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf(" ");
         for(int k=1;k<=col;k++)
             printf("%d ",k);
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             cout<<" ";
         for(int k=1;k<=col;k++)
             cout<<k<<" ";
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

PROBLEM-14

A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             printf(" ");
         for(int k=1;k<=col;k++)
         {
             printf("%c ",ch);
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             cout<<" ";
           for(int k=1;k<=col;k++)
         {
             cout<<ch<<" ";
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A

PROBLEM-15

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
             printf("%d ",k);
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             cout<<"  ";    /* double space */
         for(int k=1;k<=2*col-1;k++)
             cout<<k<<" ";
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1

PROBLEM-16

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
A B C D E F G
A B C D E
A B C
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
         {
             printf("%c ",ch);
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             cout<<"  ";    /* double space */
           for(int k=1;k<=2*col-1;k++)
         {
             cout<<ch<<" ";
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
A B C D E F G
A B C D E
A B C
A

PROBLEM-17

1
1*2
1*2*3
1*2*3*4
1*2*3*4*5
1*2*3*4
1*2*3
1*2
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf(" ");
         for(int k=1;k<=col;k++)
             if(k!=1)
             printf("*%d",k);
             else
             printf("%d",k);
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             cout<<" ";
         for(int k=1;k<=col;k++)
             if(k!=1)
             cout<<"*"<<k;
             else
             cout<<k;
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1*2
1*2*3
1*2*3*4
1*2*3*4*5
1*2*3*4
1*2*3
1*2
1

PROBLEM-18

1
1*2*3
1*2*3*4*5
1*2*3*4*5*6*7
1*2*3*4*5*6*7*8*9
1*2*3*4*5*6*7
1*2*3*4*5
1*2*3
1

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
             if(k!=1)
             printf("*%d",k);
             else
             printf("%d",k);
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1,a=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      for(int i=1;i<=num;i++)
    {
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
             if(k!=1)
             cout<<"*"<<k;
             else
             cout<<k;
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

1
1*2*3
1*2*3*4*5
1*2*3*4*5*6*7
1*2*3*4*5*6*7*8*9
1*2*3*4*5*6*7
1*2*3*4*5
1*2*3
1

PROBLEM-19

A
A*B
A*B*C
A*B*C*D
A*B*C*D*E
A*B*C*D
A*B*C
A*B
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             printf(" ");
         for(int k=1;k<=col;k++)
         {
             if(k!=1)
             printf("*%c",ch);
             else
             printf("%c",ch);
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             cout<<" ";
           for(int k=1;k<=col;k++)
         {
             if(k!=1)
             cout<<"*"<<ch;
             else
             cout<<ch;
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A*B
A*B*C
A*B*C*D
A*B*C*D*E
A*B*C*D
A*B*C
A*B
A

PROBLEM-20

A
A*B*C
A*B*C*D*E
A*B*C*D*E*F*G
A*B*C*D*E*F*G*H*I
A*B*C*D*E*F*G
A*B*C*D*E
A*B*C
A

Code


#include <stdio.h>
int main()
{
      int num,col=1;
      printf("enter number of rows : ");    /*enter odd number*/
      scanf(" %d",&num);
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             printf("  ");    /* double space */
         for(int k=1;k<=2*col-1;k++)
         {
             if(k!=1)
             printf("*%c",ch);
             else
             printf("%c",ch);
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        printf("\n");
    }
    return 0;
}


#include  <iostream>
using namespace std;
int main()
{
      int num,col=1;
      cout<<"enter number of rows : ";    /*enter odd number*/
      cin>>num;
      int space=num-1;
      char ch;
      for(int i=1;i<=num;i++)
    {
         ch='A';
         for(int j=1;j<=space;j++)
             cout<<"  ";    /* double space */
         for(int k=1;k<=2*col-1;k++)
         {
             if(k!=1)
             cout<<"*"<<ch;
             else
             cout<<ch;
             ch++;
         }
             if(i<(num/2+1))
         {
               col++;
               space--;
         }
             else
         {
               col--;
               space++;
         }
        cout<<"\n";
    }
    return 0;
}


Output

Enter number of rows :- 9

A
A*B*C
A*B*C*D*E
A*B*C*D*E*F*G
A*B*C*D*E*F*G*H*I
A*B*C*D*E*F*G
A*B*C*D*E
A*B*C
A