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

  • SEARCH
  • Home
  • 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 9252337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:55:11+00:00 2026-06-18T10:55:11+00:00

I am a new comer to programming in COBOL and I am having difficulty

  • 0

I am a new comer to programming in COBOL and I am having difficulty at something that probably should be trivial. I am wanting to find the min and max of what the user enters. When the user hits 0 the max, min, and avg should display. The avg is easy but the min and max had me wondering. If this was JAVA or another lang I’d just do some scenario with comparing MAX INT value. Unfortunately High-Value and Low-Value in COBOL are not Integer values???? So I decided to put the user’s entries in a table and then use the intrinsic functions to do what I need. However as soon as I attempt to compute like this:

 compute Min-Result = Function Min (Num-Field(ALL))

I get an error that says, “syntax error, unexpected all.” I am totally confused at this point on what to do and why I get this error. I am using OpenCOBOL 1.1 Mingw. Here is my complete code. Any help would be greatly appreciated. Anything at all. I also made sure no lines were over 72.

     identification division.
       program-id.  lab1a.
      * no envionrment division since there are no files needed, etc.
       data division.
       working-storage section.

      * declaring proper variables to store integer values
       01  Max-Result        PIC S9(5).
       01  Min-Result        PIC S9(5).
       01  Count-Val         PIC 9  Value 0.
       01  Running-Tot       PIC S9(10)v99.
       01  First-Zero        PIC 9  Value 1.
       01  Final-Format-Avg       PIC ZZZZZ9.9999.
       01  Avg-Ent              PIC S9(5)v9999.
       01  Calc-Table.
            03  Table-Record  Occurs 1 to 500 times
                              depending on Entered-Num.
                05  Num-Field    PIC S9(5).
       01  Entered-Num       PIC S9(5).

       procedure division.
       000-Main.



           perform with test after until Entered-Num = 0
              display "Enter a 4-digit number (0 to stop): "
                 with no advancing
              accept Entered-Num

              add 1 to Count-Val
              add Entered-Num to Running-Tot

              display Running-Tot
              display Count-Val
              move Entered-Num to Num-Field(Count-Val)



      * this way every time the user enters a non zero number it will be re-assigned
      * to the variable Ending-Num. If they enter zero the if condition is skipped, the
      * loop condition is tested at the top and is ended.


           end-perform.
           subtract 1 from Count-Val
           display Count-Val
           display " "  
           display " "    
      *WATCH FOR TRUNCATION ERROR.....
           Divide Running-Tot By Count-Val Giving Avg-Ent
           move Avg-Ent to Final-Format-Avg

      *******WHY DOES THIS NOT WORK???????*********************** 
           compute Min-Result = Function Min (Num-Field(ALL))
           compute Max-Result = Function Max (Num-Field(ALL))


           if First-Zero = 0
           display "The first number you entered was zero. 
 &                  Next time enter a different one."
           else                
           display "The lowest value entered: " Min-Result             
           display "The highest value entered: " Max-Result
           display "The average value entered: " 
                    Final-Format-Avg
           end-if

           stop run.
  • 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-18T10:55:13+00:00Added an answer on June 18, 2026 at 10:55 am

    You have “Entered-Num” as your Occurs Depending On field. Entered-Num by the time you use the function is zero. It should be Count-Val.

    That’s not the problem, but you asked.

    Look at a 2009 OpenCobol Programmer’s Guid, I can find no confirmation that ALL is supported.

    It will be much simpler/faster to keep a “lowest value” and a “highest value” and compare to/replace as necessary with the entered number.

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

Sidebar

Related Questions

I am a new comer to Linux Kernel Module programming. From the material that
let's say that you in your new programming work your boss comes and says
Something I don't enjoy about programming is learning a new API. For example, right
I'm new to Lua programming, having come over from python to basically make a
I'm new to graphics programming. I'm trying to create a program that allows you
I'm new to iOS programming and I am working on a easy project that
I'm a new comer to the kinect environment, and i was trying to modify
Hello i'm a new coder to android. I have a program that Plays Pauses
I'm very new when it comes to programming so maybe this is a walk
I'm new to C# and learning new words. I find it difficult to understand

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.