INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

nested for statement in c# visual studio express doesn't work

nested for statement in c# visual studio express doesn't work

(OP)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pattern_1
{
class Program
{
static void Main(string[] args)
{


for ( int i = 1; i <= 10; i++) ;

for (int j = 1; j <= 10; j++) ;

Console.Write("x");
Console.ReadLine();
}
}
}

This code should write a square block of x on the screen it doesn't what should be added to the code ?

RE: nested for statement in c# visual studio express doesn't work

If it does not do what you want it to do, exactly what does it do?

I don't know much about C, but if C is like FoxPro and most other languages, you don't have your FORs nested properly.

mmerlinn

http://mmerlinn.com

Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond

RE: nested for statement in c# visual studio express doesn't work

You definitely do not have your FORs nested correctly.

Here is a sample of nested FORs that produce 10 rows 10 characters long:


  for (int i = 1; i <= 10; i++)
  {
      for (int j = 1; j <= 10; j++)
      {
          //Output character;
          WRITESTR("X");
      }
      //New line;
      EOL();
  } 

Change your code to something similar to this and it should work.

mmerlinn

http://mmerlinn.com

Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond

RE: nested for statement in c# visual studio express doesn't work

You might also want to go back and review this thread that you started last year. If you had remembered, you would not have needed to ask a second time.

http://tek-tips.com/viewthread.cfm?qid=1718996

.

mmerlinn

http://mmerlinn.com

Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond

RE: nested for statement in c# visual studio express doesn't work

(OP)
Hi mmerlinn.com

If you don't program in C# you mustn't answer my question WRITESTR doesn't exist in Ms visual studio C# thank anyway for your help.

RE: nested for statement in c# visual studio express doesn't work

(OP)
Hi mmerlinn

I am quiet impressed on your comments but you as a programmer you don'know anything of this nguage C is not same as c++ and non behave the same,so I would appreciated that you don't comment on my code because from your comment I can conclude that you don't know anything about ms visual studio 2010 c# so keep your comments tour yourself.

RE: nested for statement in c# visual studio express doesn't work

(OP)

Panchovia,
Here is another way to write the same code but this also doesn't output the correct instructions.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Patern1_1
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 10; j++) ;//Nested for loop
{
Console.Write("x");
Console.Write("x",j);
}
Console.Write("\n");
}
Console.ReadLine();
}

}
}

output should be;
ten rows of x horizontally
ten rows of x vertically

RE: nested for statement in c# visual studio express doesn't work

(OP)
Panchovia
Problem solved here is the correct code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Patern1_1
{
class Program
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 10; j++) //Nested for loop
{
Console.Write("x");

}
Console.Write("\n");
}

Console.ReadLine();
}

}
}

RE: nested for statement in c# visual studio express doesn't work

If it is a C# question, use the C# forum

RE: nested for statement in c# visual studio express doesn't work

.


Panchovia:

I told you that I did not know C.

I never said WRITESTR() nor EOL() was part of C. I never said the example was in any form of C.

The following code (NOT C) is another example of how to nest FOR loops to get the results that you desired.

FOR i = 1 TO 10
FOR j = 1 TO 10
PRINT "X"
NEXT
PRINT CHR(13)
NEXT

This is EXACTLY the structure that you adapted in your final code.

I gave you an EXAMPLE of how to nest for loops and told you to do something SIMILAR in your code. I never said that the example had ANYTHING to do with C.

Your FINAL code is a near copy of the EXACT structure I outlined for you.

Next time you need help, even if I know the answer, LIKE I DID THIS TIME, I will not waste my time replying since you seem to think that ONLY people that know C can help you. You are wrong and the proof lies in the fact that your final code is almost an exact copy of the STRUCTURE I suggested to solve your dilemma. I detest trying to help ungrateful people who do not appreciate my help.

Apparently you wanted someone to write YOUR code for you for FREE for a SECOND time. Not me. I gave an example of the structure you needed leaving it up to you to do what you are PAID to do - ADAPT my SAMPLE code to your problem at hand.



.

mmerlinn

http://mmerlinn.com

Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond

RE: nested for statement in c# visual studio express doesn't work

I have to agree with mmerlinn: the question author (Panchovia) appears to be exceedingly ungrateful for what to me (as a C# (and other languages) programmer) seems to be very relevant advice; it puts me in mind of petulant children.

... and as xwb points out, the question should have been asked in the C# forum.

RE: nested for statement in c# visual studio express doesn't work

Rest easy guys. If Panchovia was any sort of C, C#, C++, VC programmer himself, he would have stepped through his own code using the quite useful debugger. He would then have noticed that his code structure of:

for ( int i = 1; i <= 10; i++) ;
for (int j = 1; j <= 10; j++) ;
Console.Write("x");
Console.ReadLine();

would have looped through the first 'for' 10 times, the next 'for' 10 times, then produced a single "x" which is clearly in his write statement. It's really too bad an inexperienced beginner like him has the balls to be that judgmental in this forum.

-Dave Summers-
cheers
Even more Fox stuff at:
http://www.davesummers.net/foxprolinks.htm

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close