hey guys!

do you have idea how to print a * and in a square symbol

like this

*****
* *
* *
* *
*****

i have my code in here but it didnt follow like that

I don't get you. Can you be a little more specific?

What do you have so far (for the code)? Hint: You'll need to use "for."

Well can you please post your code, or could be more specific about your problem..........:)

I think I know what you want to do, you want to print the char '*' but make them it print in a form of a square?

Like so:

*****
*\\\\\*
*\\\\\*
*****

Where the '\'s are blank space (multi spaces are not supported here I presume)

For that you would have to use a for loop

What I would do is the following:
I would have a string showing what I would want to print, and have key charectars showing where to end the line and where to show background etc.

const string box = "****************$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "****************$"+
			
			for(int i=0; i < box.Length; i++)
				{
					if(avatar[i]!='/'){
					Console.ForegroundColor = ConsoleColor.Blue;
						if(box[i]=='$'){Console.ForegroundColor = ConsoleColor.Green;Console.WriteLine("/");}
						else{Console.Write(box[i]);}
					}
				else{Console.ForegroundColor = ConsoleColor.Green;Console.Write("/");}	
				
				}

Try that

I think I know what you want to do, you want to print the char '*' but make them it print in a form of a square?

Like so:

*****
*\\\\\*
*\\\\\*
*****

Where the '\'s are blank space (multi spaces are not supported here I presume)

For that you would have to use a for loop

What I would do is the following:
I would have a string showing what I would want to print, and have key charectars showing where to end the line and where to show background etc.

const string box = "****************$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "****************$"+
			
			for(int i=0; i < box.Length; i++)
				{
					if(avatar[i]!='/'){
					Console.ForegroundColor = ConsoleColor.Blue;
						if(box[i]=='$'){Console.ForegroundColor = ConsoleColor.Green;Console.WriteLine("/");}
						else{Console.Write(box[i]);}
					}
				else{Console.ForegroundColor = ConsoleColor.Green;Console.Write("/");}	
				
				}

Try that

yap

ure ryt. like a square

*****
*\\\\\*
*\\\\\*
*\\\\\*
*****

"\" just symbol it has a blankspace
but mine is like dis

*****
*****
*****
*****
*****

I did this at University last year. Had to feed in dimensions and have it print a square of that size. Had to do it with triangles and hexegons aswell.

You need a for loop.

I did this at University last year. Had to feed in dimensions and have it print a square of that size. Had to do it with triangles and hexegons aswell.

You need a for loop.

halo sir

i tried ure code
but i have a problem
it says: Error 1 The name 'avatar' does not exist in the current context

sir Im really sorry. Im a beginner in c#, my teacher just give me us an exercise when we first met. den i really didnt understand a little about programming coz our teacher here is, just give us the code and we will self study that code, but i really cant understand whats that code for. Our teacher here didnt explain very well every codes. They think that were genius but were not. thats why i keep myself bc study and searching about whats that code for but it doesnt really helps me a lot but a little bi. I really want to have a teacher who can explain very well in every code. Most of the student here has no knowledge\learning in programming. thats why i really disappointed how da teacher teachs. I really want to become a programmer but now I doubt it.

thanks for your reply sir!!

HAppy new year

Universities are usually like that.

If you don't understand, grab a book from your library, or ask one of the teachers for help. Last thing you want is to fail and exam because you don't understand.

You should really understand the fundementals such as for loops. Thats really as basic as it gets. Do yourself a favour ... because I've been in your shoes. Go grab a book and spend a day with it before you attempt to code a solution to the problem :) My bit of advice.

commented: Good advice! +1
commented: Yeah, good advice! +6

Oops! Im sorry, I wrote one variable wrong in the code.

Here is a fixed version :

const string box = "****************$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "*//////////////*$"+
				 "****************$"+
			
			for(int i=0; i < box.Length; i++)
				{
					if(box[i]!='/'){
					Console.ForegroundColor = ConsoleColor.Blue;
						if(box[i]=='$'){Console.ForegroundColor = ConsoleColor.Green;Console.WriteLine("/");}
						else{Console.Write(box[i]);}
					}
				else{Console.ForegroundColor = ConsoleColor.Green;Console.Write("/");}	
				
				}

hey Thanks sir! for sharing your knowledge.
I promise that i will do my best to understand this.
and also with your help

thanks again sir!!

halo sir!!
Happy New Year!!

I've tried ure code its run but one thing is

the starisk should look like this

5 starisk horizontal and vertical

looks like this

*****
*|||||*
*|||||*
*|||||*
*****
Note: this " | " symbol should not be included only a atarisk

Thaks sir
Hoping for your reply.

You need a for loop over all of the rows, a for loop for each row (with an if statement to switch from printing spaces to printing stars (so at column a and column b I need a star, the rest I need spaces)). It sounded like you had a lot of it, just put some " " spaces in where appropriate.

for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (i == 0 || j == 0 || i == 7 || j == 7)
                    {
                        Console.Write("*");
                    }
                    else { Console.Write(" "); }
                }
                Console.WriteLine();
            }

shank123,
Thanks for helping the poster. However, in the spirit of truly helping posters with their homework, it's best not to give the answer away completely.

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.