Answer to Question #213792 in C for ABHINEET GAUR

Question #213792

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.


1
Expert's answer
2021-07-05T06:51:09-0400
#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;
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS