Mr. Pratheek wants to buy 10 items from the shop. He wants to store the price of all the items, Mr. Pratheek wants to list all the items which are less than a particular price. Help Mr. Pratheek to store the price of all ten items and list all the items less than a particular price
Requirements:
1: Read the price.
2: Compare the price with all prices in Mr. Pratheek items
3: Display the item number whose value is less than the price.
#include<iostream>
using namespace std;
int main(){
string items[10];
int prices[10];
cout<<"Enter the items and their prices\n";
for(int i=0; i<10; i++){
cout<<"Enter the name for item \t"<<(i+1)<<endl;
cin>>items[i];
cout<<"Enter the price for \t"<<items[i]<<endl;
cin>>prices[i];
}
int count =0;
int price_compare;
cout<<"Enter the price to compare with other prices \t"<<endl;
cin>>price_compare;
cout<<"The items whose prices is less than the particular price entered by Mr. Pratheek are \t"<<endl;
for(int i=0; i<10; i++){
if(prices[i]<price_compare){
cout<<items[i]<<endl;
count++;
}
}
cout<<"The number of item whose values are less than the price is \t"<<count<<endl;
}
Comments
Leave a comment