TechSpot

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

    Bump

    Bump

    Bump
     
  3. LIVADA

    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;
    character:char;

    begin

    write('Enter the number : ');
    readln(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!');

    writeln(character);
    end.

    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

Add New Comment

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...