+ 2

Please, write a function program that receive hight of triangle then draw it ?

* * * * * * * * * *

15th Nov 2016, 12:05 AM
cyreen
cyreen - avatar
5 odpowiedzi
+ 3
int x =5; for(int i = 1;i<=x;i++){ for(int y = 1;y<=i;y++){ cout<<"* " ; } cout<<endl; }
15th Nov 2016, 1:49 AM
Remmiq Sliv
Remmiq Sliv - avatar
+ 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; } }
15th Nov 2016, 7:18 AM
Remmiq Sliv
Remmiq Sliv - avatar
+ 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; }
15th Nov 2016, 9:15 AM
Remmiq Sliv
Remmiq Sliv - avatar
0
Thanks 🌸, and this is right but i want to solve that by using Function 😊
15th Nov 2016, 7:13 AM
cyreen
cyreen - avatar
0
can you try it on the code playground then show me the solution exactly ? 🌸
15th Nov 2016, 7:54 AM
cyreen
cyreen - avatar