dimanche 4 octobre 2015

While loop and char

The code should ask the user a letter and then show the ASCII number equivalent of it up to 3 times. But all it does is just ask the user the character 1 time and show the ASCII of it, while it should ask the question 3 times.

#include <iostream>
using namespace std;

int main()
{
  char asciiCharacterNumber = 0;

  while(asciiCharacterNumber <= 3) {
    cout << "Character:: ";
    cin >> asciiCharacterNumber;
    cout << "Value of ASCII: " <<(int)asciiCharacterNumber<<endl;
    asciiCharacterNumber++;

  }
  return 0;
}

Aucun commentaire:

Enregistrer un commentaire