# Multiplication Tables

• (2 Pages)
• 1
• 2

## 20 Replies - 2454 Views - Last Post: 04 October 2012 - 07:32 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=293734&amp;s=81685b9998a62bd7b32229c533b91a17&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 ankit.mca.aaidu

Reputation: -4
• Posts: 9
• Joined: 29-September 12

## Re: Multiplication Tables

Posted 02 October 2012 - 02:12 AM

Hello sir i have done it, it is working now
```int i,j,sum=0;
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 12; j++)
{
sum = i * j;
if (j == 1)
{
Console.Write("{0,2}", sum);
}
else
{
Console.Write("{0,4}", sum);
}
}
Console.WriteLine();
}
}

```

This post has been edited by Curtis Rutland: 02 October 2012 - 07:28 AM
Reason for edit:: stop quoting things!

### #17 November-06

• D.I.C Regular

Reputation: 47
• Posts: 449
• Joined: 04-January 11

## Re: Multiplication Tables

Posted 02 October 2012 - 06:24 PM

ankit.mca.aaidu, on 02 October 2012 - 12:03 AM, said:

Curtis Rutland, on 01 October 2012 - 07:12 AM, said:

http://blog.stevex.n...ting-in-csharp/

That's a super-handy reference for most commonly used string formatting needs. What you're looking for is called "padding". You want each column to take the same amount of space, even if the content inside is of a different size.

Hello sir please help me with this question . I am just a beginner in this field i want to do thing and i read the tutorial i am not able to implement it, please if you can do some favor to me

The tutorial is great and really easy to understand. What part is it that you don't understand and having a hard time to implement? Tell us what exactly so we could help.

Anyway, this is the first time I heard of that alignment in String.Format so I am really impressed and gave the post a plus.

I changed the \t idea into it so here's my revised code.

```            int intProduct = 0;
for (int intRow = 1; intRow <= 12; intRow++)
{
for (int intColumn = 1; intColumn <= 12; intColumn++)
{
intProduct = intRow * intColumn;
Console.Write(String.Format("{0,-5:##}", intProduct));
}
Console.WriteLine();
}

```

This post has been edited by November-06: 02 October 2012 - 06:34 PM

### #18 ankit.mca.aaidu

Reputation: -4
• Posts: 9
• Joined: 29-September 12

## Re: Multiplication Tables

Posted 04 October 2012 - 04:08 AM

November-06, on 02 October 2012 - 06:24 PM, said:

ankit.mca.aaidu, on 02 October 2012 - 12:03 AM, said:

Curtis Rutland, on 01 October 2012 - 07:12 AM, said:

http://blog.stevex.n...ting-in-csharp/

That's a super-handy reference for most commonly used string formatting needs. What you're looking for is called "padding". You want each column to take the same amount of space, even if the content inside is of a different size.

Hello sir please help me with this question . I am just a beginner in this field i want to do thing and i read the tutorial i am not able to implement it, please if you can do some favor to me

The tutorial is great and really easy to understand. What part is it that you don't understand and having a hard time to implement? Tell us what exactly so we could help.

Anyway, this is the first time I heard of that alignment in String.Format so I am really impressed and gave the post a plus.

I changed the \t idea into it so here's my revised code.

```            int intProduct = 0;
for (int intRow = 1; intRow <= 12; intRow++)
{
for (int intColumn = 1; intColumn <= 12; intColumn++)
{
intProduct = intRow * intColumn;
Console.Write(String.Format("{0,-5:##}", intProduct));
}
Console.WriteLine();
}

```

```"{0,-5:##}"
```
i am not getting this can you please explain

### #19 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,440
• Joined: 14-September 12

## Re: Multiplication Tables

Posted 04 October 2012 - 04:27 AM

ankit.mca.aaidu, on 04 October 2012 - 04:38 PM, said:

```"{0,-5:##}"
```
i am not getting this can you please explain

Those are formatting strings in C#. Here, they are used for alignment to the extreme left.

regards,
Raghav

### #20 Skydiver

• Code herder

Reputation: 4265
• Posts: 13,662
• Joined: 05-May 12

## Re: Multiplication Tables

Posted 04 October 2012 - 07:03 AM

ankit.mca.aaidu, on 04 October 2012 - 04:08 AM, said:

```"{0,-5:##}"
```
i am not getting this can you please explain

This post has been edited by Skydiver: 04 October 2012 - 07:03 AM

### #21 Curtis Rutland

• （╯°□°）╯︵ (~ .o.)~

Reputation: 4834
• Posts: 8,615
• Joined: 08-June 10

## Re: Multiplication Tables

Posted 04 October 2012 - 07:32 AM

And on that note, I'm closing this thread. If you're not willing to take our advice, then you just want people to hand you code. We don't do that here.