Answer to Question #214207 in C for ABHINEET GAUR

Question #214207

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-06T03:30:36-0400
#include <stdio.h>
/*
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.
*/


#define TOTAL_ITEMS	20
#define PARTICULAR_PRICE	3
#define NO_OF_ITEMS_LIST	10


main(void)
{
	char Items[TOTAL_ITEMS][50] ={	"Pizza"   ,"Eggs"         ,"Sugar (1 Kg)","Milk (1 Liter)","CD",
									"Pen"     ,"Pencil"       ,"Sharpner"    ,"Eraser"        ,"Pen Drive"
									"Notebook","Register"     ,"Cold-Drink"  ,"Ear Phone"     ,"Mobile Charger",
									"Mouse"   ,"Potato (1 Kg)","Towel Set"   ,"Compass"       ,"Lighter" };
	float Price[TOTAL_ITEMS] = 	{5, 2, 5, 1, 1,
								 1, 1, 1, 1, 3,
								 3, 3, 4, 10, 10,
								 15, 1, 2, 1, 2
								};
	int Index[TOTAL_ITEMS],n,m;
	printf("\n\tItem's List with Price and Index");
	for(n=0;n<TOTAL_ITEMS;n++) 
	{
		Index[n] = n+1;
		printf("\nIndex: %2d\tIntem Name: %20s\tUnit Price: US $ %.2f",Index[n],Items[n],Price[n]);
	}
	printf("\n\n\tItem's List with Price < Particular Price (US $ %.2f",PARTICULAR_PRICE);
	m=0;
	for(n=0;n<TOTAL_ITEMS;n++) 
	{
		if(Price[n] < PARTICULAR_PRICE && m <NO_OF_ITEMS_LIST) 
		{
			printf("\nIndex: %2d\tIntem Name: %20s\tUnit Price: US $ %.2f)",Index[n],Items[n],Price[n]);
			m++;	
		}
	}


}

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