🔒 Closed Pa help po sa pattern mga sir

Status
Not open for further replies.

c++ Code:

C++:
#include <iostream>
using namespace std;
int main(void) {
    for(int i=1; i<=5; i++){//do print each rows
        for(int j=i; j<=5; j++){ //print space for pyramid
        cout<<" ";
    }
    for(int k=1; k<2*i; k++){
            if(i==5 || (k==1 || k==2*i-1)){
                cout<<"&";
            }
            else{
                cout<<" ";
            }
    }
    cout<<"\n"; //move to next line
    }
}

Output:

1624000216249.webp
 

Compiler: Devcpp​

c++ Code:​

C++:
#include <iostream>
using namespace std;
int main(void) {
    for(int i=1; i<=5; i++){//do print each rows
        for(int j=i; j<=5; j++){ //print space for pyramid
        cout<<"  ";
    }
    for(int k=1; k<2*i; k++){
            if(i==5 || (k==1 || k==2*i-1)){
                cout<<"& ";
            }
            else{
                cout<<"  ";
            }
    }
    cout<<"\n"; //move to next line
    }
}

Output:

1624003030540.webp
 
Status
Not open for further replies.

About this Thread

  • 11
    Replies
  • 464
    Views
  • 4
    Participants
Last reply from:
Wakaka007

Trending Topics

Online now

Members online
884
Guests online
1,603
Total visitors
2,487

Forum statistics

Threads
2,294,858
Posts
29,093,600
Members
1,206,591
Latest member
willCOOK
Back
Top