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

Popular posts from this blog

How to create Simple ATM Machine in C++ Program||ATM Program deposit withdraw money in c++|Using CLI || C++ project with Source Code || MH Computer Academy(Muhammad Hashmi)

How to Calculate GPA/CGPA || GPA Calculator Step by Step in C++ ||Sourc...

C++ Project GYM Management System || Source Code with Explanation | MH Computer Academy || Muhammad Hashmi || Learn Programming