Direction: Make A C++ Program Using Looping For The Following Output
Direction: Make A C++ Program Using Looping For The Following Output
#include <iostream>
using namespace std;
int main()
{
int rows=5, count = 0, count1 = 0, k = 0;
while(k != 2*i-1)
{
if (count <= rows-1)
{
cout << i+k << " ";
++count;
}
else
{
++count1;
cout << i+k-2*count1 << " ";
}
++k;
}
count1 = count = k = 0;
#include <iostream>
using namespace std;
int main()
{
int rows = 5;
return 0;
}
3. A program that will allow the user to enter the number of rows and
the symbol or character you want, then the program will display
the diamond pattern with the given symbol.
#include<iostream>
using namespace std;
int main()
{
int i, j, rowNum, space;
char symbol;
space = rowNum-1;
for(i=1; i<=rowNum; i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space--;
for(j=1; j<=(2*i-1); j++)
cout<<symbol;
cout<<endl;
}
space = 1;
for(i=1; i<=(rowNum-1); i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space++;
for(j=1; j<=(2*(rowNum-i)-1); j++)
cout<<"*";
cout<<endl;
}
cout<<endl;
return 0;
}