We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hey I'm just a bit confused. Using the example input, 4 and 1 4 3 2, when you say int numElements, numElements = 4 right? And doing int arr[numElemnts] that creates an array that includes 0 through 3?
Right, 4 elements in the array, so that can be used when initializing the array. It will have 4 indices, which are then populated by the second line of input.
I get the concept but for some reason I don't understand it very well (this question I mean).
Can you please put comments in your code to explain properly what's happening here?
I would really appreciate it... thanks.
if i start loop i=o then compiler display error.when i=1 then ok but again show compiler error because quetion demand i/o using stdin and stdout so how i face difficulty ,please give me solution
because array needs an numeric value whenever you write an array and want to scan some values through condition , assign array to be '0' and size can be managed under loop..
Arrays Introduction
You are viewing a single comment's thread. Return to all comments →
My C++ Solution
Hey I'm just a bit confused. Using the example input, 4 and 1 4 3 2, when you say int numElements, numElements = 4 right? And doing int arr[numElemnts] that creates an array that includes 0 through 3?
Right, 4 elements in the array, so that can be used when initializing the array. It will have 4 indices, which are then populated by the second line of input.
in input section when i run in c++ it isnt leaving space
I get the concept but for some reason I don't understand it very well (this question I mean). Can you please put comments in your code to explain properly what's happening here? I would really appreciate it... thanks.
if i start loop i=o then compiler display error.when i=1 then ok but again show compiler error because quetion demand i/o using stdin and stdout so how i face difficulty ,please give me solution
Hey I am using visual studio and apparently int arr[numElements] wouldn't work (error of "expression must have a constant value")
because array needs an numeric value whenever you write an array and want to scan some values through condition , assign array to be '0' and size can be managed under loop..
In first for loop if you replace cin >> arr[i] with following: int x; cin >> x; arr[i] = x;
That will work otherwise it will fail if you leave your code as it is and try following values it will fail:
8 6676 3216 4063 8373 423 586 8850 6762
why is it not taking directly input in the array?
mine is also same but its showing some test case failed and compiler error occure as segmentation error.........
I did the same thing, but some of the testcases get abort called! Is this because some of the numbers are too big?
i too figured out th same logic but i can not see the output on screen ???
thanks. it worked. but I still am not able to find why my program showed "Segmentation fault" when I wrote the same exact code.
for (int i = numElements - 1; i >= 0; i--) cout << arr[i] << " "; can you plesae explain this loop's conditions
but when i do like this ..im getting runtime errors :(