While loop

Write your question here.
i am newbee to c++, i am trying to write program using while loop,

i have written code, i know it wrong, please help me

Program question:
The character 'b' is char('a'+1), 'c' is char('a'+2), etc. Use a loop to write out a table of characters with their corresponding integer values:
output should be like below
----------------------
a 97
b 98
. . .
z 122
-----------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  int main()
{

    int i = 0;
    char a;
    int b = a;

    while(i <= 26)
    {
        cout << a + 1 << '\t' << b <<endl;
        ++i;
    }

    return 0;
}
Last edited on
1
2
3
4
5
6
7
#include <iostream>
int main()
{
    int i = 'a' - 1, j = i;
    while (i++ < j+26)
        std::cout << (char)i << '\t' << i << std::endl;
}
Last edited on
Topic archived. No new replies allowed.