05 February 2022

Multidimensional Array

QUESTION:

Write a program which takes the marks of five students for three subjects and Displays them on the screen.

 #include<stdio.h> 

int main()
{
    int student = 3;
    int subject = 5;

    int marks[3][5];
    for(int i=0; i<student; i++){
        for(int j=0; j<student; j++){
            printf("Enter the marks of student %d for subject %d\n", i+1, j+1);
            scanf("%d", &marks[i][j]);
        }
    }

     for(int i=0; i<student; i++){
        for(int j=0; j<student; j++){
            printf("The marks of student %d for subject %d is : %d\n" , i+1, j+1, marks[i][j]);
        }
     }
return 0;
}

OUTPUT--->

Enter the marks of student 1 for subject 1 58 Enter the marks of student 1 for subject 2 95 Enter the marks of student 1 for subject 3 69 Enter the marks of student 2 for subject 1 98 Enter the marks of student 2 for subject 2 96 Enter the marks of student 2 for subject 3 86 Enter the marks of student 3 for subject 1 98 Enter the marks of student 3 for subject 2 98 Enter the marks of student 3 for subject 3 96
The marks of student 1 for subject 1 is : 58 The marks of student 1 for subject 2 is : 95 The marks of student 1 for subject 3 is : 69 The marks of student 2 for subject 1 is : 98 The marks of student 2 for subject 2 is : 96 The marks of student 2 for subject 3 is : 86 The marks of student 3 for subject 1 is : 98 The marks of student 3 for subject 2 is : 98 The marks of student 3 for subject 3 is : 96


No comments:

Post a Comment