team points using array:

PHOTO EMBED

Tue Feb 28 2023 10:24:54 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #c

#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
content_copyCOPY