{program ncic;
const

    home : real = 1500;
    life : real = 2000;
    motor_vehicle : real = 1400;
    business : real = 1200;

Var

    surname : array [1..2] of string; //array to save the surname for each client
    insurance : array [1..2] of string;
    premium : array [1..2] of integer;
    total_premium : real;
    client : integer;
    home_count, life_count, motorveh_count, business_count : integer;

Begin

    home_count := 0;
    life_count := 0;
    motorveh_count := 0;
    business_count := 0;

   for client := 1 to 2 do

    begin
            writeln('Enter the client Surname: ');
            readln(surname[client]);
            Writeln('Please enter the type of insurance: ');
            readln(insurance [client]);
            writeln('Enter your premium');
            readln(premium [client]);
     if (premium [client]) > 0 then
       Begin
            if (insurance [client] = 'Home') then
                    Begin

                            home_count := home_count + 1;
                    end;

       End;

    end;

    writeln('total amount :', home_count);
    End.

Recommended Answers

All 6 Replies

Could you tell me what error 106 means and where in your code it occurs?

As DDanbe said, we'd need to know what 'error 106' meant here. However, I think we can elaborate on that to make something of a teachable moment.

First, before I address that, I will point out to you that when you post code samples here, you need to indent every line of the code by at least four spaces, or the formatting won't be preserved. I suggest reading the docs for the Daniweb version of Markdown for a more detailed explanation.

With that out of the way, let's get on with the show.

While it isn't entirely clear without more context, it is safe to guess that the '106 error' is a compiler error message, that is, a report of a problem in the code that indicates a fatal error - something that prevents the compiler from finishing the compilation.

It also could be a compiler warning, which indicates something that could be a mistake, but isn't serious enough to be a showstopper - something which the compiler isn't sure is a problem, but thinks you should look into. Or, since you didn't say when it comes up, it could even be an error message that you get after it is compiled, when the program is running.

But the safe bet is that it is a compiler error message.

This means we'd need to know which compiler you are using. Different compilers - even for the same language - will have different error and warning messages and codes, so we'd have to know where to look the error up in order to figure it out.

There are several Pascal compilers around, the most notable being Delphi, FreePascal, and Gnu Pascal .

Now, Delphi is actually an Integrated Development Environment (IDE) for Object Pascal, which is a different language derived from Pascal, but the Delphi compiler will compile most Standard Pascal code as well, and is sometimes used in courses that teach Pascal (in the same way C++ compilers often double as C compilers). However, the Delphi compiler is a commercial product, so most people have shifted to using the mostly-compatible FreePascal instead.

As the name implies, FreePascal is a free, open-source compiler for Pascal and Object Pascal. It isn't as refined as Delphi, but it is pretty close, and the limited market interest in Pascal in general means it is a lot more appealing to most people than Delphi. It is often paired with Lazarus IDE, an IDE which emulated the tools found in earlier versions of Delphi.

Gnu Pascal is a part of the Gnu Compiler Collection, being a front-end for the same code generators used by gcc and g++. It isn't as commonly used as FreePascal, for a variety of reasons, but it is there. It is sometimes used with the Dev-Pascal IDE, but like with all GNU packages, it is really aimed at being used with a general-purpose programmer's editor such as vim or EMACS.

So, we will need to know which compiler gives an 'error 106' message in order to figure this out. Presumably, you know what compiler - or at least what IDE - you are using, so that's what you would need to tell us.

It would also help if you could tell us the error message itself, and if possible, what part of the code it is pointing to. If you could copy and paste the error message (or make a screen shot of it, though getting the text would be preferable), it should give us a better idea of what it is trying to tell you.

Doing a search on the error message would make sense too, but without knowing the compiler, it might be of limited use. So, Let Me Google That For You, and see what it gives us.

/me reads search results OK, it seems to be a FreePascal 'invalid numeric format' error. Oh, it could be some ancient version of Turbo Pascal with a 'string expression expected' error, but honestly, if your professor has you using an MS-DOS compiler from thirty years ago, the only solution is to get the other students together, walk out of the course en masse, and complain to the Dean of the university about the incompetent who is teaching the class.

That's about as much as we really can say, without more information. We could make some guesses, but that's all they would be, so it would be better if we refrain from that.

Hopefully, this post has taught you a few important lessons about doing the necessary research on your own before asking for help, and providing enough information when you do ask for help. Good luck with that, because no one here is going to give you this much hand-holding ever again.

Thank you guys. Sorry I didnt explain the problem.

Im using freepascal IDE for this program and Im getting and error in line 14, 15. I receive this error:

Exited with exitcode = 106.

Im trying to save data into an array. When I enter the surname and insurance type it goes well, but when it reaches to line 13 thats when I receive the error.
I believe its an invalid numeric format but I dont know how to fix it. I will appreciate any help given.

106 Invalid numeric format

Since we don't know what you typed in response to each question it appears your code is what we call fragile. Blows up when you input a numeric but answer with a character.

Screenshot_2022-01-17_225355.png

what is this error?
please answer soon!

commented: I advise to make your own discussion. Also, add details on what compiler/IDE and full code. No screenshots. +16
commented: we're not your servants to come at your beg and call instantly -4

As Rproffitt said, please make your own new threads rather than resurrecting long-dead ones.

As for the error code, that was explained in detail earlier in this thread: it indicates that you tried to read a number from a file, and got something other than a number, as defined here. The likely solution is to add a check for an end-of-file in the loop, using the function eof().

Though from the screenshot, you might be using Turbo Pascal, where the error indicates a malformed string. The correct solution to this is Don't Use Turbo Pascal.

commented: Turbo Pascal is the Blue Pill. +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.