Saturday 1 November 2014
Define a structure called cricket that will describe the following information Player name, Team name, Runs
Define a structure called cricket that will describe the following information
Player name, Team name, Runs
Using cricket, declare an array player with 10 elements and write a program to read the
information about all 10 players and print a team-wise list containing names of players
with their runs.
Player name, Team name, Runs
Using cricket, declare an array player with 10 elements and write a program to read the
information about all 10 players and print a team-wise list containing names of players
with their runs.
- #include<stdio.h>
- #include<conio.h>
- struct cricket
- { char p_name[20];
- char t_name[50];
- int run;
- };
- void main()
- { struct cricket c[10],temp;
- int i,j,n;
PRO-17
#include<stdio.h>
#include<conio.h>
struct
cricket
{ char p_name[20];
char t_name[50];
int run;
};
void
main()
{ struct cricket c[10],temp;
int i,j,n;
clrscr();
printf("Enter the no.of
Player : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{ printf("player # %d",i+1);
printf("\n\tName
: ");
scanf("%s",c[i].p_name);
printf("\n\tTeam
: ");
scanf("%s",c[i].t_name);
printf("\n\tRuns
: ");
scanf("%d",&c[i].run);
}
for(i=0;i<n;i++)
{ for(j=0;j<n;j++)
{ if(strcmp(c[i].t_name,c[j].t_name)>0)
{ temp=c[i];
c[i]=c[j];
c[j]=temp;
} } }
printf(“\n\t TEAM WIZE PLAYER
LIST”);
printf(“\n\t
------------------------------------“);
for(i=0;i<n;i++)
{ printf("\nplayer # %d ",i+1);
printf("\n\tPlayer
Name : %s",
c[i].p_name);
printf("\n\tPlayre
Team : %s",
c[i].t_name);
printf("\n\tPlayer
Runs : %d",c[i].run);
}
getch();
}
OUTPUT:
Enter
the no.of Player : 10
player
# 1
Name : sachin
Team :
Runs : 102
player
# 2
Name : Sahevagh]
Team :
Runs : 85
player
# 3
Name : Ponting
Team : Aus
Runs : 75
player
# 4
Name : Gibbs
Team : Sauth
Runs : 78
player
# 5
Name : kalis
Team : sauth
Runs : 45
|
player
# 6
Name : jaysurya
Team : shrilanka
Runs : 35
player
# 7
Name : Lee
Team : Aus
Runs : 15
player
# 8
Name : Yuvaraj
Team :
Runs : 78
player
# 9
Name : pollok
Team : sauth
Runs : 33
player
# 10
Name : Raina
Team :
Runs : 88
TEAM WIZE PLAYER LIST
-----------------------------------
player
# 1
Name : jaysurya
Team : shrilanka
Runs : 35
player
# 2
Name : Gibbs
Team : Sauth
Runs : 78
player
# 3
Name : kalis
Team : sauth
Runs : 45
player
# 4
Name : pollok
Team : sauth
Runs : 33
player
# 5
Player Name : Sahevagh]
Playre Team :
Player Runs : 85
player
# 6
Player Name : Yuvaraj
Playre Team :
Player Runs : 78
player
# 7
Player Name : Sachin
Playre Team :
Player Runs : 102
player
# 8
Player Name : Raina
Playre Team :
Player Runs : 88
player
# 9
Player Name : Lee
Playre Team : Aus
Player Runs : 15
player
# 10
Player Name : Ponting
Playre Team : Aus
Player Runs : 75
|
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment