0

tell me a mistake

#include <iostream> using namespace std; int main() { int b[2]={1,3}; cout << b<<endl; return 0; }

28th Sep 2016, 9:30 PM
David Viadas
David Viadas - avatar
7 odpowiedzi
+ 5
cout << b[0] <<endl; cout << b[1] <<endl;
28th Sep 2016, 10:06 PM
Zen
Zen - avatar
+ 2
Zen is right. Or you can use a loop if you want to make the code easier to scale for larger arrays.
29th Sep 2016, 1:47 AM
Ryne
Ryne - avatar
+ 1
you're right! thank you so much
28th Sep 2016, 10:09 PM
David Viadas
David Viadas - avatar
0
Thanks Zen!!
29th Sep 2016, 3:43 AM
Devansh Kaushik
Devansh Kaushik - avatar
0
it will print 1 on the screen. if u want all the elements then u should use loop statements or index no:
29th Sep 2016, 10:14 AM
Jithin cruze
0
#include <iostream> using namespace std; int main() { int b[2]={1,3}; for (int x = 0 ; x < 2 ; x++){ cout << b[x]<<endl; } return 0; }
9th Oct 2016, 7:33 AM
Shahriar Ferdous
Shahriar Ferdous - avatar
- 5
remove "=" int b [2]{1,3};
28th Sep 2016, 9:50 PM
Łukasz Walancik
Łukasz Walancik - avatar