Pascal Q: How to convert a integer to char?

By Fortify
May 19, 2008
  1. Wondering how to convert an integer into character.
    I want to convert:

    Mark: Grade:
    91-100 into A
    71-90 into B
    50-70 into C
    25-49 into D
    0-24 into E
  2. Fortify

    Fortify TS Rookie Topic Starter Posts: 28




    LIVADA TS Rookie

    Well it is kind a possible with arrays, but the simplest way to do this is:

    program prog_1;

    var number:integer;


    write('Enter the number : ');

    if (number>0) and (number<24) then character:='E'
    else if (number>25) and (number<49) then character:='D'
    else if (number>50) and (number<70) then character:='C'
    else if (number>71) and (number<90) then character:='B'
    else if (number>91) and (number<100) then character:='A'
    else writeln('UNDEFINED!');


    In this way u get what u wanted.
    Maybe there is a easier way, but i just cant think about anything simpler than this one.
    Sorry for bad english.
  4. Fortify

    Fortify TS Rookie Topic Starter Posts: 28

    Thanks mate! I already figured it out myself long time ago.
Topic Status:
Not open for further replies.

Similar Topics

Create an account or login to comment

You need to be a member in order to leave a comment
TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...

Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.