EEEEERRRRRAAAA
Honorary Poster
- Joined
- Oct 28, 2018
- Posts
- 442
- Reaction
- 48
- Points
- 248
- Age
- 25
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
#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
}
}
thank you po sirc++ 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:
View attachment 1464735
what if sir.. if diko gamitin si void main? if int main lang gawin ko sir?thank you po sir
Alisin molang po yung void then lagyan mo ng return 0 sa last part ng int main.what if sir.. if diko gamitin si void main? if int main lang gawin ko sir?
sir? paano lagyan ng space sa last row.. &Alisin molang po yung void then lagyan mo ng return 0 sa last part ng int main. ar
Alisin molang po yung void then lagyan mo ng return 0 sa last part ng int main.
#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
}
}