2D Array Project 1

#include <stdio.h>
int main(){
//Task: To intake marks of 7 students in Sem1 and Sem2 and calculate their sum i.e total final Sem marks.
//asking options: 1.Sem1 feeding 2.Sem2 feeding 3.Show Sem1 4.Show Sem2 5.Show both 6.Show aggregate.
int marks[2][7];            //2 rows & 7 columns
int wish;
printf("Press 1 to continue & 0 for exit\n");
scanf("%d",&wish);
while(wish==1){
    int choice;
        printf("1.Sem1 feeding\n2.Sem2 feeding\n3.Show Sem1\n4.Show Sem2\n5.Show both\n6.Total marks\n");
        scanf("%d",&choice);
        switch(choice){
            case 1:
            for(int i=0;i<7;i++){
            printf("Enter the marks of student %d for Semester 1:\n",i+1);
            scanf("%d",&marks[0][i]);
            }
            break;
            case 2:
            for(int i=0;i<7;i++){
            printf("Enter the marks of student %d for Semester 2:\n",i+1);
            scanf("%d",&marks[1][i]);
            }
            break;
            case 3:
            for(int i=0;i<7;i++){
            printf("The marks of student %d in 'Semester 1' is %d\n",i+1,marks[0][i]);
            }
            break;
            case 4:
            for(int i=0;i<7;i++){ printf("The marks of student %d in 'Semester 2' is %d\n",i+1,marks[1][i]); } break; case 5: for(int i=0;i<7;i++){ printf("The marks of student %d in 'Semester 1 & 2' are %d, %d\n",i+1,marks[0][i],marks[1][i]); } break; case 6: for(int i=0;i<7;i++){ printf("The Total marks of student %d is %d\n",i+1,marks[0][i]+marks[1][i]); } break; default: printf("Invalid entry\n"); break; } printf("Press 1 to continue & 0 for exit\n"); scanf("%d",&wish); } return 0;}
//Programer : Tejas 

Output


Comments

Popular Posts