1 Answers

প্রোগ্রাম ১ঃ

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

#include 
int main()
{
    int i,j,rows;
    cout<<"Enter the number of rows: ";
    cin>>rows;
    for(i=1;i<=rows;++i)
    {
        for(j=1;j<=i;++j)
        {
           cout<<"* ";
        }
        cout<<"\n";
    }
    return 0;
}
Program 2:
            *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *

#include 
int main()
{
    int i,space,rows,k=0;
    cout<<"Enter the number of rows: ";
    cin>>rows;
    for(i=1;i<=rows;++i)
    {
        for(space=1;space<=rows-i;++space)
        {
           cout<<"  ";
        }
        while(k!=2*i-1)
        {
           cout<<"* ";
           ++k;
        }
        k=0;
        cout<<"\n";
    }
    return 0;
}

Program 3:
           *
          ***
         *****
        *******
       *********
      ***********
     *************
    ***************
   *****************
  *******************
 *********************
***********************
#include

int main(){

    int x,y;
    char star = '*';
    char space = ' p ';
    int temp;
    int numSpaces = 0;

    for(x=1; x <= 23; x++){ 

        if((x%2) != 0){
            numSpaces = (23 - x) / 2;  // Calculate number of spaces to add

            for(int i = 0; i < numSpaces; i++) // Apply the spaces
            {
                cout << " ";
            }       

            for(y=1; y <= x ; y++){     

                cout << star;                   

            }   
            cout << endl;
        }
    }
    return 0;
}
2953 views

Related Questions