Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need some help

CarmichaelCarmichael Posts: 2Member
Hey there

I'm all fairly new when it comes to programming and don't know much at all, but for an assignment I need to write a pascal program that will allow a user to type a short sentance and then when they press enter it will display relevant ASCII values, example being:

User input = Good Day

Output screen = 71 111 111 100 32 68 97 121

I have been able to do it so that one character can be inputted and outputted, but can't do it for multiple one's, any help would be greatly appreciated!!!!!!

Carmichael



Comments

  • zibadianzibadian Posts: 6,349Member
    : Hey there
    :
    : I'm all fairly new when it comes to programming and don't know much at all, but for an assignment I need to write a pascal program that will allow a user to type a short sentance and then when they press enter it will display relevant ASCII values, example being:
    :
    : User input = Good Day
    :
    : Output screen = 71 111 111 100 32 68 97 121
    :
    : I have been able to do it so that one character can be inputted and outputted, but can't do it for multiple one's, any help would be greatly appreciated!!!!!!
    :
    : Carmichael
    :
    :
    :
    :
    Create a for-do loop, which loops through all the characters in the user input, and for each of those characters use the code you got.
    Hint 1: a string is a 1-based array of char. Implicitly defined as:
    [code]
    type
    string: array[1..255] of char;
    [/code]
    Hint 2: Use Length() to get the number of chars.
  • CarmichaelCarmichael Posts: 2Member
    I appreciate your input my friend, and I know you are probably talking in very simplistic terms, but when it comes to programming I hardly make layman level at the moment, so sadly even basic talk can go over my head.

    I wrote a very very basic bare bones program that will do it for one character input, as follows:

    program ascii;

    uses
    crt;

    var
    sentence:char;
    exit_out:string;

    begin

    writeln ('Please type a sentence');
    readln (sentence);
    clrscr;
    writeln (ord(sentence));
    readkey;

    end.

    But of course it doesn't work for an entire sentance, how would I utilise and impliment loops etc to make it do what I want it to, I wouldn't even know where to start tinkering with it.

    Carmichael








    : : Hey there
    : :
    : : I'm all fairly new when it comes to programming and don't know much at all, but for an assignment I need to write a pascal program that will allow a user to type a short sentance and then when they press enter it will display relevant ASCII values, example being:
    : :
    : : User input = Good Day
    : :
    : : Output screen = 71 111 111 100 32 68 97 121
    : :
    : : I have been able to do it so that one character can be inputted and outputted, but can't do it for multiple one's, any help would be greatly appreciated!!!!!!
    : :
    : : Carmichael
    : :
    : :
    : :
    : :
    : Create a for-do loop, which loops through all the characters in the user input, and for each of those characters use the code you got.
    : Hint 1: a string is a 1-based array of char. Implicitly defined as:
    : [code]
    : type
    : string: array[1..255] of char;
    : [/code]
    : Hint 2: Use Length() to get the number of chars.
    :

  • zibadianzibadian Posts: 6,349Member
    [b][red]This message was edited by zibadian at 2006-5-6 7:23:44[/red][/b][hr]
    : I appreciate your input my friend, and I know you are probably talking in very simplistic terms, but when it comes to programming I hardly make layman level at the moment, so sadly even basic talk can go over my head.
    :
    : I wrote a very very basic bare bones program that will do it for one character input, as follows:
    :
    [code]
    : program ascii;
    :
    : uses
    : crt;
    :
    : var
    : sentence:char;
    : exit_out:string;
    :
    : begin
    :
    : writeln ('Please type a sentence');
    : readln (sentence);
    : clrscr;
    [red]for i := 1 to length(sentence) do
    writeln (ord(sentence[i]));[/red]
    : readkey;
    :
    : end.
    [/code]
    :
    : But of course it doesn't work for an entire sentance, how would I utilise and impliment loops etc to make it do what I want it to, I wouldn't even know where to start tinkering with it.
    :
    : Carmichael
    :
    :
    :
    :
    :
    :
    :
    :
    : : : Hey there
    : : :
    : : : I'm all fairly new when it comes to programming and don't know much at all, but for an assignment I need to write a pascal program that will allow a user to type a short sentance and then when they press enter it will display relevant ASCII values, example being:
    : : :
    : : : User input = Good Day
    : : :
    : : : Output screen = 71 111 111 100 32 68 97 121
    : : :
    : : : I have been able to do it so that one character can be inputted and outputted, but can't do it for multiple one's, any help would be greatly appreciated!!!!!!
    : : :
    : : : Carmichael
    : : :
    : : :
    : : :
    : : :
    : : Create a for-do loop, which loops through all the characters in the user input, and for each of those characters use the code you got.
    : : Hint 1: a string is a 1-based array of char. Implicitly defined as:
    : : [code]
    : : type
    : : string: array[1..255] of char;
    : : [/code]
    : : Hint 2: Use Length() to get the number of chars.
    : :
    :
    :
    See the red part.
Sign In or Register to comment.