also @ TechSpot: Building a Thin Mini-ITX PC: Small and Silent Performance

Pascal Q: How to convert a integer to char?

Discussion in 'Software Apps' started by Fortify, May 19, 2008.

  1. Fortify Newcomer, in training Posts: 28

    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 Newcomer, in training Posts: 28

    Bump

    Bump

    Bump
  3. LIVADA Newcomer, in training

    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 Newcomer, in training Posts: 28

    Thanks mate! I already figured it out myself long time ago.