2----Draw triangle shape in C++ / C code in which user enter its desire size of triangle. Using nested for loop and asterisk
Code:
#include<iostream>
using namespace std;
void main()
{
for(int i=0;i<5;i++)
{
for(int j=0;j<i;j++)
cout<<"*";
cout<<endl;
}
for(int i=4;i>=0;i--)
{
for(int j=0;j<i;j++)
cout<<"*";
cout<<endl;
}
system("pause");
}
Output
0 Questions:
Post a Comment