#include <stdio.h>
/*Write C code that does the following operation.
- Asks and gets the number of WINs (3 points/win), DRAWs (1 points/draw) and LOSSes (0 points/loss) for four football teams.
- Records them in a multidimensional array.
- Calculates the total scores.
- Reports the score table.*/
int main() {
int score[3][3];
for(int i=0;i<3;i++)
{
printf("enter win draw and loss of team %d: ",i+1);
scanf("%d %d %d ",&score[i][0],&score[i][1],&score[i][2]);
}
printf("team name\t win\t draw\t loss\t points\n");
for(int i=0;i<3;i++)
{
int points=score[i][0]*3+score[i][1]*1;
printf("\nteam %d\t\t %d\t\t %d\t\t %d\t\t %d\n",i+1,score[i][0],score[i][1],score[i][2],points);
}
return 0;
}
output:
enter win draw and loss of team 1: 2
1
1
1
enter win draw and loss of team 2: 2
3
1
enter win draw and loss of team 3: 3
3
2
team name win draw loss points
team 1 2 1 1 7
team 2 1 2 3 5
team 3 1 3 3 6
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter