Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3974062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:31:27+00:00 2026-05-20T04:31:27+00:00

I have to print a 5×5 table with alphabets in them, like: <table> <tr>

  • 0

I have to print a 5×5 table with alphabets in them, like:

<table>
 <tr> <td>A</td> <td>B</td> <td>C</td> <td>D</td> <td>D</td>

etc.. the letters are in fact a link, so they will be like:

<td> <a href='/someplace'>A</a> </td>

Those links have all the tendency to change often and I don’t fancy hard-coding them and replacing them since they will be appearing in quite a few pages. So I thought I would write up a function to output the whole structure.

Yes, it’s pretty straight forward, get the for loop to behave like:

  StringBuilder alphabets = new StringBuilder("<table class='table'>");
  for(int i=65; i<=87; i++)
  {
      //Do stuff here to calculate if i mod 5 is zero and add <tr> accordingly.
      //Use Convert.ToChar(i); to get the wanted structure.
  }

Then it hit me, I could possibly do it in a better, “clever” way using nested for loops,

for(i=1; i<=5; i++)
{
    alpbahets.Append("<tr>")
    for(j=1; j<5; j++)
    {
        //Get the <a > link string here.
    }
    alphabets.Append("</tr");
}

Now the question is, what can I do to relate i AND j to get them into the range of 65-87?
(A-W, since it’s a 5×5 grid I will skip the last iteration and manually add YZ in one td).

I have tried (i*10 + j) + 54) (yea, I don’t know what I was thinking), but it doesn’t work.

This might be an EXTREMELY stupid question, sorry, but what is the way to get this done in nested for loops? Or is there any other better way? I am asking because I am very curious to know more (and dumb that I already don’t).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:31:27+00:00Added an answer on May 20, 2026 at 4:31 am

    What about just introducing a variable char letter = 'A'; out side your loops?

    Then after using it, call letter++; to move to the next letter in the alphabeth.

    This will make your program more readable also, and won’t force other programmers to see some calculation including i and j that ends up as a letter.

    Simplicity is often the best solution 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a function to print database table to an array like this
I have a page with a Print link that takes the user to a
My silverlight application will have print capability, the printing module is created in separated
The situation is as follows:- We have n number and we have print them
I have a situation where I have to print out a NUL character if
if for example i have : #define PRINT(x) fprintf(stderr, x); and in code i
Is there a way to have rails print out a number with commas in
I have a generic Print method that iterates over a list and simply prints
I have the following code print Starting stage 1<br> # Something that takes about
I have a javascript backed 'print' button on my webpage where the user can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.