using function to return a string...etc...

Hiya,

i am a beginner in pascal and i need some help with a certain problem i found when trying to work pascal...this is the question..
i wish to...'write a function to return a string consisting of number of repetitions of the character required. ' I really need help with it.. i have a basic idea but i cannot do it! Can anyone please help?

thank you in Anticipation.

sweetfaith

Comments

  • : Hiya,
    :
    : i am a beginner in pascal and i need some help with a certain problem i found when trying to work pascal...this is the question..
    : i wish to...'write a function to return a string consisting of number of repetitions of the character required. ' I really need help with it.. i have a basic idea but i cannot do it! Can anyone please help?
    :
    : thank you in Anticipation.
    :
    : sweetfaith
    :
    I think you could do a for loop!

    for loop 1 to the number u want do
    writeln(' What string you want to put in')


    ok here is an exaple

    program forloop;
    uses crt;
    var
    loop : integer;
    mark : integer;
    total : integer;

    begin
    for loop := 1 to 10 do
    begin
    write(' Enter the mark: ');
    readln(mark);
    total := total + mark;
    writeln(total);
    end;

    the for loop is used to make a copy of enter the mark 10 times and add them together that will display the total mark! very simple program! hope this is what you want!
  • : Hiya,
    :
    : i am a beginner in pascal and i need some help with a certain problem i found when trying to work pascal...this is the question..
    : i wish to...'write a function to return a string consisting of number of repetitions of the character required. ' I really need help with it.. i have a basic idea but i cannot do it! Can anyone please help?
    :
    : thank you in Anticipation.
    :
    : sweetfaith
    :
    This kinda smells like more schoolwork......pass your function the character and number of repeats needed. Set the result to the string that you construct in your function. I'm sure your textbook has a whole section about writing functions.
  • hi
    actually no, it is not school work... i am just giving pascal a go on my own actually, just as a programming hobby. I have no tutors, just me and my book and i just asked a question to get a better insite of things.. I would appreciate it if you just help me a bit and not just say that it is homework. I signed up for help not for judging. thank you. Please help..the question is once again :
    'write a function to return a string consisting of number of repetitions of the character required.' Would appreciate the help given to me.

    thank you in anticipation

    sweetfaith



    : : Hiya,
    : :
    : : i am a beginner in pascal and i need some help with a certain problem i found when trying to work pascal...this is the question..
    : : i wish to...'write a function to return a string consisting of number of repetitions of the character required. ' I really need help with it.. i have a basic idea but i cannot do it! Can anyone please help?
    : :
    : : thank you in Anticipation.
    : :
    : : sweetfaith
    : :
    : This kinda smells like more schoolwork......pass your function the character and number of repeats needed. Set the result to the string that you construct in your function. I'm sure your textbook has a whole section about writing functions.
    :

  • : hi
    : actually no, it is not school work... i am just giving pascal a go on my own actually, just as a programming hobby. I have no tutors, just me and my book and i just asked a question to get a better insite of things.. I would appreciate it if you just help me a bit and not just say that it is homework. I signed up for help not for judging. thank you. Please help..the question is once again :
    : 'write a function to return a string consisting of number of repetitions of the character required.' Would appreciate the help given to me.

    I cant really blame him for assuming that. The way you are wording it, it definitely sounds like you copied it right out of a homework assignment.

    But whether it is homework or not, it is much better if you try to solve the problem on your own and then ask specific questions if you have problems. If you are indeed learning as a hobby, having someone here write the above function won't teach you anything. But if you do some research into how FOR loops work, you'll have that written in no time, and probably never have to research FOR loops again because the knowledge will just stick with you...
  • Although he did make an assumption, he actually did answer your question:
    : : pass your function the character and number of repeats needed. Set the result to the string that you construct in your function. I'm sure your textbook has a whole section about writing functions.

    anyways, here's a function header for a start:
    [code]
    FUNCTION ChrToStr(Ch : Char; Count : Byte) : String;
    [/code]
    Ch = character to be repeated
    Count = Number of times
    ChrToStr = String to be returned

    Hope this helps,
    Phat Nat

    : hi
    : actually no, it is not school work... i am just giving pascal a go on my own actually, just as a programming hobby. I have no tutors, just me and my book and i just asked a question to get a better insite of things.. I would appreciate it if you just help me a bit and not just say that it is homework. I signed up for help not for judging. thank you. Please help..the question is once again :
    : 'write a function to return a string consisting of number of repetitions of the character required.' Would appreciate the help given to me.
    :
    : thank you in anticipation
    :
    : sweetfaith
    :


Sign In or Register to comment.

Howdy, Stranger!

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

Categories