Need help with C++ programming.
-
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.
-
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.
-
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.
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
-
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
-
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.
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" ;
-
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" ;
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
-
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.