[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Listing letters...

Posted on 2000-03-09
4
Medium Priority
?
225 Views
Last Modified: 2010-04-15

ok... i want to make a program that lists chars to the screen in this order:
a,b,c,d, and so on until it comes to z... then it shall start at aa and move upwards like this: aa, ab, ac...

how do i do this ?
0
Comment
Question by:GrApZ2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 2602718
This can easily be done using nested loops (as I assume you'd also like 'ba bb bc' ;-)

#include <stdio.h>

void main ( void)
{
char c1, c2;

for ( c1 = 'a'; c1 <= 'z'; c1++)
{
 printf ( "%c", c1);
}

printf ( "\n");

for ( c1 = 'a'; c1 <= 'z'; c1++)
{
  for ( c2 = 'a'; c2 <= 'z'; c2++)
  {
   printf ( "%c%c", c1, c2);
  }
}
}
0
 
LVL 86

Expert Comment

by:jkr
ID: 2602726
A little correction to 'beautify'  the output:

#include <stdio.h>

void main ( void)
{
char c1, c2;

for ( c1 = 'a'; c1 <= 'z'; c1++)
{
 printf ( "%c", c1);
}

printf ( "\n");

for ( c1 = 'a'; c1 <= 'z'; c1++)
{
  for ( c2 = 'a'; c2 <= 'z'; c2++)
  {
   printf ( "%c%c ", c1, c2);  /* note the space */
  }
 printf ( "\n");  /* a line feed when we start with a new 1st letter */
}
}

It's hard to elaborate that, as I think it's self-explaining, but please ask if you encounter problems or need more information...
0
 

Author Comment

by:GrApZ2
ID: 2602763
but... ok... how do i include captial letters and numbers... and make it countinue forever (at least almost)
0
 
LVL 86

Expert Comment

by:jkr
ID: 2605705
Hmm, capital letter is quite easy, just use

for ( c1 = 'A'; c1 <= 'Z'; c1++)
{
  for ( c2 = 'A'; c2 <= 'Z'; c2++)
  {
   printf ( "%c%c ", c1, c2);  /* note the space */
  }
 printf ( "\n");  /* a line feed when we start with a new 1st letter */
}

instead... how would you like to use the numbers?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question