How to store char as variables in pascal and other questions












-1














I am very new to programming and I'm trying to make a program (in Pascal) that stores a letter chosen by the user several times, like this:



sizes: set of char = ['a' .. 'f'];

Nings: integer = 1 or 2 or 3 or 4 or 5;

writeln ('Choose the number of pizzas (min:1 e max:5)');

read (Nings);

while (Nings => 1) do

Begin

writeln ('a- extra small');

writeln ('b- small');

writeln ('c- regular');

writeln ('d- medium');

writeln ('e- large');

writeln ('f- extra large');

read (sizes);

Nings:= Nings-1;

End;


As I said I'm very new at this, and I wanted to store a number of letters equal to the number of pizzas chosen, and I don't know how. (This is just a piece of the code.) Any help would be appreciated!










share|improve this question





























    -1














    I am very new to programming and I'm trying to make a program (in Pascal) that stores a letter chosen by the user several times, like this:



    sizes: set of char = ['a' .. 'f'];

    Nings: integer = 1 or 2 or 3 or 4 or 5;

    writeln ('Choose the number of pizzas (min:1 e max:5)');

    read (Nings);

    while (Nings => 1) do

    Begin

    writeln ('a- extra small');

    writeln ('b- small');

    writeln ('c- regular');

    writeln ('d- medium');

    writeln ('e- large');

    writeln ('f- extra large');

    read (sizes);

    Nings:= Nings-1;

    End;


    As I said I'm very new at this, and I wanted to store a number of letters equal to the number of pizzas chosen, and I don't know how. (This is just a piece of the code.) Any help would be appreciated!










    share|improve this question



























      -1












      -1








      -1







      I am very new to programming and I'm trying to make a program (in Pascal) that stores a letter chosen by the user several times, like this:



      sizes: set of char = ['a' .. 'f'];

      Nings: integer = 1 or 2 or 3 or 4 or 5;

      writeln ('Choose the number of pizzas (min:1 e max:5)');

      read (Nings);

      while (Nings => 1) do

      Begin

      writeln ('a- extra small');

      writeln ('b- small');

      writeln ('c- regular');

      writeln ('d- medium');

      writeln ('e- large');

      writeln ('f- extra large');

      read (sizes);

      Nings:= Nings-1;

      End;


      As I said I'm very new at this, and I wanted to store a number of letters equal to the number of pizzas chosen, and I don't know how. (This is just a piece of the code.) Any help would be appreciated!










      share|improve this question















      I am very new to programming and I'm trying to make a program (in Pascal) that stores a letter chosen by the user several times, like this:



      sizes: set of char = ['a' .. 'f'];

      Nings: integer = 1 or 2 or 3 or 4 or 5;

      writeln ('Choose the number of pizzas (min:1 e max:5)');

      read (Nings);

      while (Nings => 1) do

      Begin

      writeln ('a- extra small');

      writeln ('b- small');

      writeln ('c- regular');

      writeln ('d- medium');

      writeln ('e- large');

      writeln ('f- extra large');

      read (sizes);

      Nings:= Nings-1;

      End;


      As I said I'm very new at this, and I wanted to store a number of letters equal to the number of pizzas chosen, and I don't know how. (This is just a piece of the code.) Any help would be appreciated!







      char pascal






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 21:05









      ankabout

      668210




      668210










      asked Nov 12 at 20:09









      Gabriela

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You need to review what a set type is. Internally a set consists of single bits for each value the set can hold. Your set of char can only keep track of one 'a', one 'b', etc ('a' is, or is not, in the set; 'b' is, or is not, in the set ...).



          Since you need to keep track of up to five pizzas, each one of any of the six sizes you offer, you need to store the size information in an array, say array[1..5] of char. You can use the Nings variable as index to the sizes array, like read(sizes[Nings]) in the while loop.



          Btw, variables of limited range are declared in one of two ways:



          1) as a type that declares the values and then a variable of that type:



          type
          TNings = 1..5;
          var
          Nings: TNings;


          2) using numeric or character subranges as type in the variable declaration:



            Nings: 1..5





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269381%2fhow-to-store-char-as-variables-in-pascal-and-other-questions%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need to review what a set type is. Internally a set consists of single bits for each value the set can hold. Your set of char can only keep track of one 'a', one 'b', etc ('a' is, or is not, in the set; 'b' is, or is not, in the set ...).



            Since you need to keep track of up to five pizzas, each one of any of the six sizes you offer, you need to store the size information in an array, say array[1..5] of char. You can use the Nings variable as index to the sizes array, like read(sizes[Nings]) in the while loop.



            Btw, variables of limited range are declared in one of two ways:



            1) as a type that declares the values and then a variable of that type:



            type
            TNings = 1..5;
            var
            Nings: TNings;


            2) using numeric or character subranges as type in the variable declaration:



              Nings: 1..5





            share|improve this answer




























              0














              You need to review what a set type is. Internally a set consists of single bits for each value the set can hold. Your set of char can only keep track of one 'a', one 'b', etc ('a' is, or is not, in the set; 'b' is, or is not, in the set ...).



              Since you need to keep track of up to five pizzas, each one of any of the six sizes you offer, you need to store the size information in an array, say array[1..5] of char. You can use the Nings variable as index to the sizes array, like read(sizes[Nings]) in the while loop.



              Btw, variables of limited range are declared in one of two ways:



              1) as a type that declares the values and then a variable of that type:



              type
              TNings = 1..5;
              var
              Nings: TNings;


              2) using numeric or character subranges as type in the variable declaration:



                Nings: 1..5





              share|improve this answer


























                0












                0








                0






                You need to review what a set type is. Internally a set consists of single bits for each value the set can hold. Your set of char can only keep track of one 'a', one 'b', etc ('a' is, or is not, in the set; 'b' is, or is not, in the set ...).



                Since you need to keep track of up to five pizzas, each one of any of the six sizes you offer, you need to store the size information in an array, say array[1..5] of char. You can use the Nings variable as index to the sizes array, like read(sizes[Nings]) in the while loop.



                Btw, variables of limited range are declared in one of two ways:



                1) as a type that declares the values and then a variable of that type:



                type
                TNings = 1..5;
                var
                Nings: TNings;


                2) using numeric or character subranges as type in the variable declaration:



                  Nings: 1..5





                share|improve this answer














                You need to review what a set type is. Internally a set consists of single bits for each value the set can hold. Your set of char can only keep track of one 'a', one 'b', etc ('a' is, or is not, in the set; 'b' is, or is not, in the set ...).



                Since you need to keep track of up to five pizzas, each one of any of the six sizes you offer, you need to store the size information in an array, say array[1..5] of char. You can use the Nings variable as index to the sizes array, like read(sizes[Nings]) in the while loop.



                Btw, variables of limited range are declared in one of two ways:



                1) as a type that declares the values and then a variable of that type:



                type
                TNings = 1..5;
                var
                Nings: TNings;


                2) using numeric or character subranges as type in the variable declaration:



                  Nings: 1..5






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 12 at 21:52

























                answered Nov 12 at 21:33









                Tom Brunberg

                13.1k62239




                13.1k62239






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269381%2fhow-to-store-char-as-variables-in-pascal-and-other-questions%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python