MArking Scheme DS Lab Assignment 1
MArking Scheme DS Lab Assignment 1
Data Structures
Lab Assessment 1
Question : Hari, as an owner in a Cricket League, has received auction amounts for
different players and is currently in the process of team selection. Hari aims to add players
based on his personal preferences and subsequently compute the remaining balance.
Furthermore, he seeks to ascertain the feasibility of forming a team of n players according
to his priority list. Help Hari in verifying whether the team can be successfully formed
based on his preferences.
Requirements:
Step1: Read the number of players (n) to be purchased from the keyboard.
Step2: For each player:
a. Read the cost of the player (cost) purchased by Hari from the keyboard.
b. If the cost is sufficient to purchase the player:
- Display the player's cost.
#include <stdio.h>
void main()
{
int n, HariBalanceAmount=2500000,Num_of_Players=0,i;
int cost;
printf("Enter the number of Players to be purchased:\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the cost of Player %d purchased by Hari\n",i);
scanf("%d",&cost); Q1 (0.5)
if(cost<=HariBalanceAmount) or if(HariBalanceAmount>=cost) Q2 (0.5)
{
printf("Player %d Cost =%d\n",i,cost);
HariBalanceAmount= HariBalanceAmount-cost; Q3 (0.5)
printf("Available Balance Amount is %d\n",HariBalanceAmount);
Num_of_Players++;
}
else
{
Q4
printf("Player %d can't be purchased by Hari\n",i); Q4 a. ( 0.25)
printf("Available Balance Amount is %d\n",HariBalanceAmount); Q4 b. (0.25)
}
}
printf("Number of Players Purchased by Hari = %d\n",Num_of_Players);
if(Num_of_Players==n ) Q5 (0.5)
Sample Output2