Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it
Showing posts with label Star Pattern. Show all posts
Showing posts with label Star Pattern. Show all posts

14 Nov 2022

C++ program to create star pattern

WRITE A PROGRAM TO PRINT THE FOLLOWING STAR PATTERN

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int i, j, n;
 cout<<"Enter number of rows\n";
 cin>>n;
 for(i=1;i<=n;i++)
  {
   for(j=1;j<=i;j++)
    {
     cout<<"*";
    }
   cout<<endl;
  }
 for(i=n-1;i>=1;i--)
  {
   for(j=1;j<=i;j++)
    {
     cout<<"*";
    }
   cout<<endl;
 }
 getch();
}

28 Aug 2013

STAR PATTERN2

Write a program to print the following star pattern

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

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int i,j,n;
 cout<<"Enter number of rows"<<endl;
 cin>>n;
 for(i=n;i>=1;i--)
  {
   for(j=1;j<=i;j++)
    {
     cout<<"*";
    }
   cout<<endl;
 }
 getch();
}

==OUTPUT==


2 Apr 2013

STAR PATTERN3

Q)Write a Program to Print The Following Star Pattern in c++
    *
   * *
  * * *
 * * * *
* * * * *

Sol) 
#include<iostream.h>
#include<conio.h>

 void main()
{
    clrscr();
    int i,j,n,k;
    cout<<"Enter number of rows"<<endl;
    cin>>n;
    
    for(i=1;i<=n;i++)
          {
              for(j=n-1;j>=i;j--)
                {
                    cout<<" ";
                 }
             for(k=1;k<=i;k++)
                {
                   cout<<"*";
                }
            cout<<endl;
        }
    getch();
}

                                                    ===OUTPUT===
Enter number of rows
5
    *
   * *
  * * *
 * * * *
* * * * *

28 Mar 2013

STAR PATTERN5

Q) Write a Program to Print The Following Star Pattern in c++
     *
   ***
  *****
 *******
*********

Sol)


#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int i,j,n,k;
 cout<<"Enter number of rows"<<endl;
 cin>>n;
 for(i=1;i<=n;i++)
 {
  for(j=1;j<=n-i;j++)
  {
   cout<<" ";
  }
   for(k=1;k<=2*i-1;k++)
    {
     cout<<"*";
    }
    cout<<endl;
 }
 getch();
}

                                               ===OUTPUT===

STAR PATTERN1

Q) Write a Program to Print The Following Star Pattern in c++
      *
      **
      ***
      ****
      *****

Sol)

#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  int i,j,n;

   cout<<"Enter number of rows"<<endl;
  cin>>n;
 
  for(i=1;i<=n;i++)
     {
         for(j=1;j<=i;j++)
           {
               cout<<"*";
           }
        cout<<endl;
     }
 getch();
}

                                     ===OUTPUT===

10 Mar 2013

STAR PATTERN4

Q.) Write a Program to Print The Following Star Pattern in c++
          *****
          ****
          ***
          **
          *

Sol) 
 #include<iostream.h>
#include<conio.h>

void main()
{

    clrscr();
    int i,j,n;
    cout<<"Enter number of rows"<<endl;
    cin>>n;
    for(i=n;i>=1;i--)
     {
         for(j=1;j<=i;j++)
             {
                  cout<<"*";
             }
        cout<<endl;
     }

   getch();
}

                                              =OUTPUT=

Enter number of rows 5
*****
****
***
**
*