how can I GET A EMPTY SQUARE İN C++ LİKE THİS;
* * *
* *
* * * PLS HELP ME

restrictment commented: Read the rules please +0

Recommended Answers

All 4 Replies

My advise for you, first try to think and solve this problem by your own if even so you don't get to a conclusion of the problem then come back here and post what you have done so far, just don't come here and expect everyone to do all the work for you.. you must first show some effort.

Jiwe

ı wrote smthing but it gives infinite stars

#include <iostream>
using namespace std;
int main()
{
	int i,j,n;
	cout<<"enter the a side of square";
	cin>> n;
	for(i=1;i<=n;i++)
	{
		cout<<"*";
	
	for(j=1;j=n;j++)
		cout<<"*";
    
    return(0);
    }
  }

by the way asking for something means not always get smthng effortless..

It's easy,

INPUT size of square side
OUTPUT size times *
OUTPUT * then output size-2 times space then output *
do this size-2 times
then finish it with
OUTPUT size times *

Try to translate this into c++

Hope this helps

for(j=1;j=n;j++) You are not comparing j with n, you are setting j to n, therefore an infinite loop.

You need to think deeper about what you are trying to accomplish. Use pencil and paper to figure out what kind of loops you need, and how many.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.