+ 1

What is wrong on this code why I can't get the price when I type the number from itemnum??

#include <iostream> using namespace std; int main() { Int itemnum[5]; itemnum [0]=120; itemnum [1]=121; itemnum [2]=122; itemnum [3]=123; itemnum [4]=124; double price[5]; price [0]=2.50; price [1]=4.50; price [2]=7.35; price [3]=8.50; price [4]=12.75; total=0; For (int i =0;i <5,i++) {cin>>itemnum [i]; } return 0; }

13th Nov 2019, 11:45 PM
Shofi Uddin
6 Réponses
+ 2
Shofi Uddin here is the rectified code. Always make it readable for the user. https://code.sololearn.com/cB0p3p5eo6o5/?ref=app
14th Nov 2019, 3:19 AM
Avinesh
Avinesh - avatar
+ 3
Dude remove the cin statement from for loop and insert the cout statement inside.
14th Nov 2019, 2:32 AM
Avinesh
Avinesh - avatar
+ 2
There were a lot of errors in this code. But majority of them were due to case sensitivity Check this code out:- https://code.sololearn.com/cbk40r3o4mc4/?ref=app
14th Nov 2019, 2:37 AM
Arsenic
Arsenic - avatar
0
cout << itemnum [i] << '=' << double price[i] << endl;
14th Nov 2019, 12:01 AM
rodwynnejones
rodwynnejones - avatar
0
It's not working it's said error
14th Nov 2019, 12:13 AM
Shofi Uddin
0
#include <iostream> using namespace std; int main() { Int itemnum[5]; itemnum [0]=120; itemnum [1]=121; itemnum [2]=122; itemnum [3]=123; itemnum [4]=124; double price[5]; price [0]=2.50; price [1]=4.50; price [2]=7.35; price [3]=8.50; price [4]=12.75; total=0; For (int i =0;i <5,i++) {cin>>itemnum [i]; } Cout <<itemnum[i]<<'='<<double price[i]<<endl; return 0; }
14th Nov 2019, 12:13 AM
Shofi Uddin