Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:56:41+00:00 2026-06-01T15:56:41+00:00

I’m new to Pascal and I am trying to write a simple program, but

  • 0

I’m new to Pascal and I am trying to write a simple program, but an having trouble passing values between functions. This is a small piece of what I have:

program numberConverter;

const
    maxValue = 4999;
    minValue = 1;

var num: integer;

function convertNumeral(number: integer):string;
var j: integer;
begin
if ((number < minValue) OR (number > maxValue)) then
    begin
    writeln(number);
    writeln('The number you enter must be between 1 and 4999. Please try again:');
    read(j);
    convertNumeral := convertNumeral(j);
    end
else 
 if (number >= 1000) then
convertNumeral := 'M' + convertNumeral(number -1000)
{more code here, left it out for space}
end;

begin
    writeln;
    writeln('Enter an integer between 1 and 4999 to be converted:');
    read(num);
    writeln;
    writeln(num);
    writeln(convertNumeral(num));
end.

My problem is that the value from the writeln(converNumeral(num)), mainly ‘num’, does not get passed to the convertNumeral function and was wondering if Pascal even does this. I figure its because I haven’t declared number to be a variable, but when I do I get a compile error that it can’t complete the second if statement. Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:56:42+00:00Added an answer on June 1, 2026 at 3:56 pm

    Yes, values definitely get passed to functions. I promise that num really does get passed to convertNumeral. Within that function, number acquires whatever value resides in num. Perhaps there’s a problem with how you’re observing the behavior of your program.

    Changes you make to number, if any, will not be reflected in num. The parameter was passed by value, so number stores a copy of the value stored in num; they’re two distinct variables. You can use var to pass parameters by reference, if that’s what you want.

    Each recursive call to convertNumeral gets a new instance of number, so changes made to number, if any, will not appear once the function returns to the caller. Each call gets its own versions of number and j.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.