while loop

question: Use a while loop to fill an array of the appropriate size and type with all the lowercase letters (a through z).
i need to know how to do this for an upcoming test! please help :)
Yeah you can examine his code:

1
2
3
4
5
6
7
char array[26];
int index=0;
for(char i=a;i<z;i++)
{
     array[index]=i;
     index++;
}


First you declare an array of char type with 26 elements, then an int index, and initialize it to 0. Then in the loop, a char i is declared and initialized to a,then the loop runs as far as i<z, so the value of i, is what fills up the array.

Hope it HELPS!!!
thank you!!
Topic archived. No new replies allowed.