+ 8
How to make the following pattern
* ** *** **** *****
5 Réponses
+ 4
#include <iostream>
using namespace std;
int main() {
int i, j, k, n;
cout << "Enter the number of star lines: ";
cin >> n;
cout << endl;
for(i = 0; i < n; ++i) {
for(j = 0; j < (n-i-1); ++j) {
cout << " ";
}
for(k = 0; k < (2 * i + 1); ++k) {
cout << "*";
}
cout << endl;
}
return 0;
}
+ 4
visit Hebron.Amjadcloud.com
its full of simular codes In c++ they would be a great benefit in expanding your concept
+ 4
ah. it's better to define the counters I,....
In the loop not in the start of the code
+ 1
#include <iostream>
#include <conio.h>
void main()
{
int i,space,rows,k=0;
cout<<"Enter the number of rows: ";
cin>>rows;
for(i=1;i<=rows;++i)
{
for(space=1;space<=rows-i;++space)
{
cout<<" ";
}
while(k!=2*i-1)
{
cout<<"* ";
++k;
}
k=0;
cout<<"\n";
}
}
0
#include <iostream>
using namespace std;
void main()
{
for (int i = 1; i<=5 ; i++)
{
for( int j = 1 ; j <= i ; j++)
{
cout <<"*";
cou << "\n";
}
}
}