+ 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; }
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
+ 3
Dude remove the cin statement from for loop and insert the cout statement inside.
+ 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
0
cout << itemnum [i] << '=' << double price[i] << endl;
0
It's not working it's said error
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;
}