0

New start an new project

Here I share my code please can u explain me what to do here it show all the itemnum = price but I want to cin put a item number is times as many times the want and the the total at end not when u time a item num show when I time.... Is very hard to write and explain is very easy to do in paper and pen is very hard to do in programm when I don't don't what exactly function to use #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; double total=0; for(int i=0;i<5;i++) { cin>>itemnum[i]; total += price[i]; cout<< "Item number " << itemnum[i]<<" costs " <<price[i]<<endl; } // i am trying to show the price at end the total. Here only displays me all the itemnum= price. cout << "The total price of the items is: " << total << endl; return 0; }

15th Nov 2019, 1:45 AM
Shofi Uddin
1 Réponse
+ 2
Shofi Uddin Dude are you still stuck with this?? Ok listen this works now. Give your input as- Number of items to be purchased Item numbers with a space For example- 3 123 121 124 https://code.sololearn.com/cB0p3p5eo6o5/?ref=app
15th Nov 2019, 3:20 AM
Avinesh
Avinesh - avatar