+ 2
Please, write a function program that receive hight of triangle then draw it ?
* * * * * * * * * *
5 Respuestas
+ 3
int x =5;
for(int i = 1;i<=x;i++){
for(int y = 1;y<=i;y++){
cout<<"* " ;
}
cout<<endl;
}
+ 3
here you go
void tri(int s){
for(int i = 1;i<=s;i++){
for(int y = 1;y<=i;y++){
cout<<"* " ;
}
cout<<endl;
}
}
+ 2
okay here is the complete code... the whole spoon
you can just copypaste it and run it for yourself.
#include <iostream>
using namespace std;
//the function
void tri(int s){
//first loop that creates the lines
for(int i = 1;i<=s;i++){
for(int y = 1;y<=i;y++){
//fill the lines with the correct amount of chars
cout<<"* " ;
}
cout<<endl;
}
}
int main() {
//call the function 2 times
tri(4);
tri (5);
return 0;
}
0
Thanks 🌸, and this is right but i want to solve that by using Function 😊
0
can you try it on the code playground then show me the solution exactly ? 🌸