In: Computer Science
Write a C++ program that accepts a single integer value entered by user. If the value entered is less than one the program prints nothing. If the user enters a positive integer n. The program prints n x n box drawn with * characters. If the user enters 1 , for example the program prints *.
If the user enter a 2, it prints
**
**
that is , a 2x2 box of * symbols.
#include <iostream>
using namespace std;
int main(){
int n,i,j;
cin>>n;
if(n>=1){
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
cout<<"*";
}
cout<<endl;
}
}
return 0;
}
Screenshot of the program :
Output 1:
Output 2 :
Output 3 :
Output 4:
NOTE: If you want to change something , please let me know through comments; I will surely revert back to you.
Please give a up vote .....
Thank you...