- 1

Arrays are easy

//C++ #include< iostream> using namespace std; int main() { int A[4] {0,1,5}; cout<<A[3] ; cout<<A[4] ; cout<<A; return 0; } find following without WAP 1>>cout<<A[3] ; 2>>cout<<A[4]; 3>>//Output of cout<<A; Explain ur answer

8th Sep 2017, 3:21 AM
aryan goyat
17 Respostas
+ 12
arr[4] causes array index out of bound error, results in undefined behaviour, in your case - Garbage values, which is whatever was left behind in the memory block. An array of size 4 has index 0, 1, 2 and 3 only.
8th Sep 2017, 4:48 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Am I dumb or does this make no sense
8th Sep 2017, 3:30 AM
Enzo
Enzo - avatar
+ 5
code is wrong
8th Sep 2017, 4:00 AM
Manual
Manual - avatar
+ 4
sure here you go :D
8th Sep 2017, 4:57 AM
Lord Krishna
Lord Krishna - avatar
+ 3
gg with the challenge And I do not understand, what you mean. Your code did not have values for [3] [4] you printed errors
8th Sep 2017, 4:28 AM
Manual
Manual - avatar
+ 3
What is WAP?
8th Sep 2017, 4:29 AM
Manual
Manual - avatar
+ 3
Do you understand arrays? Your code gives out of index errors.
8th Sep 2017, 4:44 AM
Manual
Manual - avatar
+ 3
Pls upvote šŸ˜ž
8th Sep 2017, 4:54 AM
aryan goyat
+ 2
rest arr[3] =0 as it has been allocated a blank space for array but has not been assigned so default is 0.
8th Sep 2017, 4:51 AM
aryan goyat
+ 2
And cout<<A; gives memory address of A[0] u may verify by cout<<&A[0];
8th Sep 2017, 4:52 AM
aryan goyat
0
Hey i have nt written the complete code do u want me to include library and all that
8th Sep 2017, 4:13 AM
aryan goyat
0
U may check now this in C++ see it works but i want a ans without WAP.
8th Sep 2017, 4:21 AM
aryan goyat
8th Sep 2017, 4:25 AM
aryan goyat
0
Pls upvote if u learned something from it.
8th Sep 2017, 4:28 AM
aryan goyat
0
Writing A Programme
8th Sep 2017, 4:29 AM
aryan goyat
0
U may check the attached code see it results in a output i don't want to explain what is it let someone else explain šŸ˜Špls upvote
8th Sep 2017, 4:30 AM
aryan goyat