Answer :
Answer:
1. Without Recursives, Write a program to print pattern of *
#include<iostream>
// Comments are used for explanatory purpose
int main()
{
// Declare integer number, Num
int Num;
cout<<"Pattern Number: ";
cin>>NUM;
// Print * in descending order
for(j = Num; j<0;j--)
{
for(i=Num;i >i-1;i--)
{
// Print *
cout<<"*";
}
// Print new line
cout<"\n";
}
// Print * in ascending order
for(int asc=0; asc< Num; asc++)
{
for(asc2=0;asc2<=asc;asc2++)
{
// Print *
cout<<"*";
}
// Print new line
cout<"\n";
}
return 0;
}
// End Program
2. Using Recursive
#include <iostream>
using namespace std;
void printStars(int lines);
int main()
{
// prompt the user to enter a number
int lines;
cin>> lines;
printStars(int lines);
return 0;
}
void printStars(int lines)
{
if (lines < 1)
return;
// to print the stars of a particular row
if (i <= lines)
{
cout << "* ";
// recursively print rest of the stars of the row
printPatternRecur(lines, i + 1);
}
else
{
// Enter new line
cout << endl;
// print stars
printPatternRecur(lines-1, 1);
}
}
// End Program
Read more on Brainly.com - https://brainly.com/question/15089715#readmore