This is a C++ program that uses loops to print a square pattern of stars. The pattern is printed in a single loop. Here is an explanation of how the program works:
#include<iostream> using namespace std; int main() { int i,j,n; cout<<"\nEnter the value:"; cin>>n; for(i=1;i<=n;i++) { cout<<"\n"; for(j=1;j<=n;j++) { if(i==1||i==n||j==1||j==n) cout<<" *"; else cout<<" "; } } return 0; }To download raw file Click Here
Enter the value:10
* * * * * * * * * *
* *
* *
* *
* *
* *
* *
* *
* *
* * * * * * * * * *
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions