Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need help with C++ programming.

Need help with C++ programming.

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelpquestion
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    B Sho
    wrote on last edited by
    #1

    I wanted to verify if I am right on this question for college class. #6. Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the “lotterynumbers” array. (4 points) I came up with... int TestScores[5]; TestScores[0] = 99; TestScores[1] = 100; TestScores[2] = 88; Correct me if I am wrong :) Thank you.

    CPalliniC A J L 4 Replies Last reply
    0
    • B B Sho

      I wanted to verify if I am right on this question for college class. #6. Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the “lotterynumbers” array. (4 points) I came up with... int TestScores[5]; TestScores[0] = 99; TestScores[1] = 100; TestScores[2] = 88; Correct me if I am wrong :) Thank you.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      That's not a single statement.

      Veni, vidi, vici.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • B B Sho

        I wanted to verify if I am right on this question for college class. #6. Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the “lotterynumbers” array. (4 points) I came up with... int TestScores[5]; TestScores[0] = 99; TestScores[1] = 100; TestScores[2] = 88; Correct me if I am wrong :) Thank you.

        A Offline
        A Offline
        Andre Kraak
        wrote on last edited by
        #3

        That are in effect 4 statements. You might want to read this: Initializing Aggregates[^]. What you are looking for is:

        int TestScores[5] = { 99, 100, 88 };

        Note that the remaining elements of the array are initialized with zero, so that the following is the same as the previous statement.

        int TestScores[5] = { 99, 100, 88, 0, 0 };

        0100000101101110011001000111001010000010

        B 1 Reply Last reply
        0
        • A Andre Kraak

          That are in effect 4 statements. You might want to read this: Initializing Aggregates[^]. What you are looking for is:

          int TestScores[5] = { 99, 100, 88 };

          Note that the remaining elements of the array are initialized with zero, so that the following is the same as the previous statement.

          int TestScores[5] = { 99, 100, 88, 0, 0 };

          0100000101101110011001000111001010000010

          B Offline
          B Offline
          B Sho
          wrote on last edited by
          #4

          Thank you! I understand what I did wrong... i needed a single statement, not a multiple statement. Thanks again.

          1 Reply Last reply
          0
          • B B Sho

            I wanted to verify if I am right on this question for college class. #6. Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the “lotterynumbers” array. (4 points) I came up with... int TestScores[5]; TestScores[0] = 99; TestScores[1] = 100; TestScores[2] = 88; Correct me if I am wrong :) Thank you.

            J Offline
            J Offline
            jackheroes
            wrote on last edited by
            #5

            with int array, you can do the following idiom. TestScores[5] = { 99, 100, 88 } // [3],[4] are initialized with 0 with char array, in addition to the grammar above, you can wchar_t[4] = L"jac" ;

            D 1 Reply Last reply
            0
            • J jackheroes

              with int array, you can do the following idiom. TestScores[5] = { 99, 100, 88 } // [3],[4] are initialized with 0 with char array, in addition to the grammar above, you can wchar_t[4] = L"jac" ;

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              jackheroes wrote:

              // [3],[4] are initialized with 0

              Not necessarily.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              1 Reply Last reply
              0
              • B B Sho

                I wanted to verify if I am right on this question for college class. #6. Write a single statement that assigns the values 99, 100 and 88 to an integer array named TestScores. Use the C++ notation used for the “lotterynumbers” array. (4 points) I came up with... int TestScores[5]; TestScores[0] = 99; TestScores[1] = 100; TestScores[2] = 88; Correct me if I am wrong :) Thank you.

                L Offline
                L Offline
                lrinish
                wrote on last edited by
                #7

                that's 4 statements not a single one it is going to look something like this. int array[3] = {99,100,88};

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups