Code:#include<iostream.h> #include<conio.h> class item{ public: char name[20]; int price[10]; void enter(); }; void item::enter() { for(int i=0;i<5;i++){ cout<<"\nEnter name of Item "<<(i+1); cin>>name[i]; cout<<"\nEnter the price in Rs : "; cin>>price[i]; } } void main() { clrscr(); int a; item chips; chips.enter(); cout<<"/nEnter the max price : "; cin>>a; for(int j=0;j<5;j++){ if(chips.price[j]<=a) cout<<"/n"<<chips.name[j]; } getch(); }
the loop does not work correctly
please help!