Welcome to Dream.In.Code
Become a C# Expert!

Join 150,399 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 971 people online right now. Registration is fast and FREE... Join Now!




multiplication table

 
Reply to this topicStart new topic

multiplication table, please help me with this

brokensilver
2 Mar, 2008 - 02:38 PM
Post #1

New D.I.C Head
*

Joined: 2 Mar, 2008
Posts: 2

please help me create a multiplication table using the WHILE LOOP...

IPB Image

I cant really create a good one but I already have my codes here in my notebook...

and, I am not really sure if it is correct or not, so I need someone to help me...

please post your codes here so that i can compare it with mine, which really needs improvement.

this is my code by the way

CODE
x=1;
do
{
a=x*1;
b=x*2;
c=x*3;
d=x*4;
e=x*5;
f=x*6;
g=x*7;
h=x*8;
i=x*9;
j=x*10;
do
{
Console.Write(a+" "+b+" "+c+" "+d+" "+e+" "+f+" "+g+" "+h+" "+i+" "+j);
}
x=x+1;
}while (x<=10);

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Multiplication Table
2 Mar, 2008 - 03:33 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 314 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
This solution better lends itself to a for loop but here is a while loop equivalent that can help you out.

csharp

int i = 1;

// From 1 to 10 rows
while (i <= 10) {
int j = 1;
string line = "";

// From 1 to 10 columns
while (j <= 10) {
// Multiply column by row and add a space
line += (i * j).ToString() + " ";
j++;
}

// Print the row
Console.WriteLine(line);

// Move to next row and continue
i++;
}


Just read through the in-code comments and you should get the idea. Enjoy!

"At DIC we be multiplication table creating code ninjas!" decap.gif

This post has been edited by Martyr2: 2 Mar, 2008 - 03:35 PM
User is offlineProfile CardPM
+Quote Post

brokensilver
RE: Multiplication Table
4 Mar, 2008 - 05:17 AM
Post #3

New D.I.C Head
*

Joined: 2 Mar, 2008
Posts: 2

thanks dude, hope that it will be right...

im not really good at looping but im good in the basics happy.gif

anyways, more thanks
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:49PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month