0

Why the computer stop working when I type the number and press enter

#include <iostream> using namespace std; int main(){ int barcode[5]; barcode [0]=0120001; barcode [1]=0121002; barcode [2]=0122003; barcode [3]=0122004; barcode [4]=0122005; double price[5]; price [0]=2.50; price [1]=4.50; price [2]=7.35; price [3]=8.50; price [4]=12.75; Char= 'F'; double total=0; int itemnum ; cin >> itemnum ; int item[n]; for(int i=0;i<itemnum;i++){ cin>> " barcode (type F to finish)" itemnum[i]; } for(int i=0;i<n;i++){ for(int j=0;j<5;j++){ if(itemnum [i] == barcode [j]){ total+=price[j]; } } } cout << "The total price of the items is: " << total << endl; Char= 'F'; return 0; }

18th Nov 2019, 6:59 PM
Shofi Uddin
1 Antwort
+ 1
Hellow, welcome to sololearn! I don't understand C++ but it might be due to an infinite loop. When this happens make sure to try and stop the program with task manager (if ur using windows). You can access task manager by pressing ctrl + shift + esc This problem usually affects memory so if you unusually have a high memory usage on task manager that might be the problem Note- next time try and put your code in a sololearn file (with the plus sign). This will make it easier to read and can get you more responses Hope this helps and have a good one, good luck :)
18th Nov 2019, 8:38 PM
Minerals2016
Minerals2016 - avatar