CODING JOY

The stunning potpourri of coding and mundane life

PLUS SIGN IN C++ LANGUAGE



AMRUHA AHMED
15th December,2023.



This article will aid you in the creation of a plus sign in C++ using a combination of nested loops. blog1

DELVING DEEPER:

BREAK-UP OF THE PATTERN:

blog1

PROGRAM:

                
                    #include<iostream>
                    using namespace std;
                    int main()
                    {
                        int m=5;//spaces before the *
                        int i,j;//loop counters
                        for(i=1;i<=11;i++)
                        {
                            if(i!=6)//when the iteration hasn't reached the middle of the pattern
                            {
                                for(j=1;j<=m;j++)
                                cout<<"  ";
                                cout<<"* ";
                            }
                            else//outer loop has reached the middle of the pattern
                            {
                                for(j=1;j<=11;j++)//printing the horizontal line
                                cout<<"* ";
                            }
                            cout<<"\n";
                        }
                    }
                                                       
             
         
CODE COPIED

OUTPUT:

blog1