why this wont work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why this wont work

Měhřâđ Hîđđěň: #include <iostream> using namespace std; int main() { int b; int a[10]; for(int i=0;i<5;i++) { cout«"Inter number: "; cin»a[i]; a[i]=b; } for(int i=0;i<5;i++) { cout«a[i]«endl; } return 0; }

25th Jul 2017, 3:00 PM
Mehrad Rafati
Mehrad Rafati - avatar
2 Answers
+ 10
Where are you trying to run this code? Code Playground? Input and loops don't work well together on Code Playground, but your code should work fine of desktop compilers. Also, remember to use << and >> instead of « and ».
25th Jul 2017, 3:04 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
a[i] = b; Is invalid, you did not initialize the value of b... unless you are doing that intentionally?
25th Jul 2017, 3:20 PM
aklex
aklex - avatar