Array that will store answers to questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amie857
    New Member
    • Nov 2006
    • 10

    Array that will store answers to questions

    i have got to create an array which will stored the answers to my questions any idea on how to do this
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by amie857
    i have got to create an array which will stored the answers to my questions any idea on how to do this
    Hi. Not enough information
    What data type will your answers be?
    How many answers do you need to store?

    Comment

    • amie857
      New Member
      • Nov 2006
      • 10

      #3
      i have got to store ten answers. i am making a maths application and everytime they answer a question the question and answer needs to be stored and then produced on the answer page

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        Originally posted by amie857
        i have got to store ten answers. i am making a maths application and everytime they answer a question the question and answer needs to be stored and then produced on the answer page
        and what type of data is the answer? is it an integer, float, string?

        Comment

        • amie857
          New Member
          • Nov 2006
          • 10

          #5
          interger. you have to add a and b together to create the maths results

          Comment

          • willakawill
            Top Contributor
            • Oct 2006
            • 1646

            #6
            Originally posted by amie857
            interger. you have to add a and b together to create the maths results
            ok. here is a code snippet that will help you on your way

            Code:
            int a;
            int b;
            int result[10];
            for (int i = 0; i < 10; i++) {
               cout << "Input the first number for sum " << i + 1;
               cin >> a;
               cout << "Input the second number for sum " << i + 1;
               cin >> b;
               result[i] = a + b;
            }

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by willakawill
              ok. here is a code snippet that will help you on your way

              Code:
              int a;
              int b;
              int result[10];
              for (int i = 0; i < 10; i++) {
                 cout << "Input the first number for sum " << i + 1;
                 cin >> a;
                 cout << "Input the second number for sum " << i + 1;
                 cin >> b;
                 result[i] = a + b;
              }
              Will that really help much in the VB forum? Looks like Java, to me. Here's a quick attempt at a VB6 translation. For VB.Net, don't ask me. :)
              Code:
              Dim a As Integer
              Dim b As Integer
              Dim result(1 To 10) As Integer
              For i = 1 To 10
                a = Cint(InputBox("Input the first number for sum" & i))
                b = Cint(InputBox("Input the second number for sum" & i))
                result(i) = a + b
              Next
              P.S. This was just done on the fly in the editor here, so may need some debugging.

              Comment

              • willakawill
                Top Contributor
                • Oct 2006
                • 1646

                #8
                Originally posted by Killer42
                Will that really help much in the VB forum? Looks like Java, to me.
                Oops. glad someone is cleaning up after me. I thought I was answering a c++ question.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by willakawill
                  Oops. glad someone is cleaning up after me. I thought I was answering a c++ question.
                  Well, I supose not knowing c++, it's simpler for me. I just read the message and if my reaction is "what the bleep does that mean?" then something's wrong (hopefully with the post, and not me). :)

                  Comment

                  • willakawill
                    Top Contributor
                    • Oct 2006
                    • 1646

                    #10
                    Originally posted by Killer42
                    Well, I supose not knowing c++, it's simpler for me. I just read the message and if my reaction is "what the bleep does that mean?" then something's wrong (hopefully with the post, and not me). :)
                    Well that's me, jack of all trades, master of none :)

                    Comment

                    Working...