Need help with ASCII program

I need to input two characters, and print out the symbol with it's corresponding ASCII number saying which one is larger. What am I doing wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//char_compare.cpp

#include <iostream.h>
#include <iomanip.h>

           
   int main()
           
   
   { 
   
      int choice;
      char symbol1, symbol2;
   
      choice=1;
      while(choice==1)
      {
         cout<<"\nEnter in the first character: ";
         cin>>symbol1;
         cout<<"\nEnter in the second character: ";
         cin>>symbol2;
      }
   
      if (symbol1 > symbol2)
      {
         cout<<symbol1<<static_cast<char>(symbol1)<<" is larger than "<<symbol2<<static_cast<char>(symbol2);
      }
      else if (symbol2 > symbol1)
      {
         cout<<symbol2<<static_cast<char>(symbol2)<<" is larger than "<<symbol1<<static_cast<char>(symbol1);
      }
   
      return 0;
   }
Last edited on
1) Creating an infinite loop on lines 16-22
2) Casting char to char on lines 26,30
Last edited on
Topic archived. No new replies allowed.