Hi,

I have given a assignment to make a program using arrays input match played and win for five cricket teams in the month of April then give the ratings of the teams like “CITY BANK CRICKET RATING.

So far I have done this:

#include<stdio.h>
#include<conio.h>
void main (void)
{
int a,ab[5,2],ad[5],b;
float ac[5],ae[5];
clrscr();
printf("\nfive teams are: \n1.pakisatan\n2.south africa\n3.india\n4.australia\n5.england");
for (a=0;a<=4;a++)
{
if (a==0)
printf("\n\t\tpakistan");
if (a==1)
printf("\n\t\tsouth africa");
if (a==2)
printf("\n\t\tindia");
if (a==3)
printf("\n\t\taustralia");
if (a==4)
printf("\n\t\tengland");
printf("\nmatch played: ");
scanf("%d",&ab[a,0]);
printf("\nwin:          ");
scanf("%d",&ab[a,1]);
ac[a]=(ab[a,1]*100.0)/ab[a,0];
ae[a]=ac[a];
printf("\nwin percent is %.2f",ac[a]);
}
for (a=0;a<=4;a++)
{
ad[a]=0;
for (b=0;b<=4;b++)
{
if (ac[a]<ac[b])
ad[a]=b;
}
ac[ad[a]]=0;
}
clrscr();
printf("\t\tCITY BANK CRICKET RATINGS");
printf("\n\t\t________________________");
printf("\n\n\n\t\tteams\t\twin percent");
for (a=0;a<=4;a++)
{
if (ad[a]==0)
printf("\n%d\t\tpakistan\t\t\t%.2f",a+1,ae[ad[a]]);
if (ad[a]==1)
printf("\n%d\t\tsouth africa\t\t%.2f",a+1,ae[ad[a]]);
if (ad[a]==2)
printf("\n%d\t\tindia\t\t\t%.2f",a+1,ae[ad[a]]);
if (ad[a]==3)
printf("\n%d\t\taustralia\t\t%.2f",a+1,ae[ad[a]]);
if (ad[a]==4)
printf("\n%d\t\tengland\t\t%.2f",a+1,ae[ad[a]]);
}
getch();
}

But there is something wrong sorting, I couldn't figured out yet. I tried everything I could but no result.

Please Please tell me what should I do to make it work.

Waiting for reply.

> void main (void)
main returns an int

> int a,ab[5,2],ad[5],b;
A 2D array would be int ab[5][2]; Likewise, accessing it would be scanf("%d",&ab[a][0]);

> void main (void)
main returns an int

> int a,ab[5,2],ad[5],b;
A 2D array would be int ab[5][2]; Likewise, accessing it would be scanf("%d",&ab[a][0]);

Thanks for replying.

I tried doing what you said but still no improvement.

Please help me out!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.