Monday, September 3, 2018

NESTED LOOP PATTERN PART -1 - ALL STARS

// Program to print Pattern - square of Stars
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines to print
cout<<"Enter Number "; cin>>num;
char ch; cout<<"Enter Character "; cin>>ch;
int r,c;
for( r=1; r<=num; r++)// Outer Loop to print lines - Vertical Count
{
for( c=1 ; c<=num; c++)// Inner Loop for Horizontal Count
{
cout<<ch; // will print * in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

No comments:

Post a Comment