Write a program to display following output using nested for loop
OUTPUT:
****** *
* *
* *
*****
Source Code:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
for(int r=1;r<=5;r++) //for number of rows
{
for(int c=1;c<=5;c++)
{
if(r==1 || r==5 || c==1 || c==5) // condition
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
getch();
// MH Computer Academy
}
Comments
Post a Comment