Print student grades in a matrix

Asked

Viewed 69 times

0

I wanted to print all the notes at the end of the program, but I’m not getting it. Ex:

Aluno 1: Nota 2
Aluno 2: Nota 4
etc...
        #include <stdio.h>
            #define resp 3
            #define nota_aluno 3

            int main()
            {
                char gabP[resp];
                float nota[nota_aluno];
                int i, j;
                char respA;
                char continuar;
                int notaA;
                int aluno = 20;

                printf("Digite o gabarito da prova:\n");
                for(i = 0; i < resp; i++)
                {
                    do
                    {
                        printf("Questao %d:", i + 1);
                        scanf(" %c", &gabP[i]);
                    } while(gabP[i] != 'a' && gabP[i] != 'b' && gabP[i] != 'c' && gabP[i] != 'd' && gabP[i] != 'e');
                }

                do
                {

                    for (j=0; j<nota_aluno; j++){
                    notaA=0;
                    printf("Digite as respostas do aluno %d:\n", j+1);


                    for(i = 0; i < resp; i++)
                    {
                        do
                        {
                            printf("Questao %d: ", i + 1);
                            scanf(" %c", &respA);
                        }
                        while (respA != 'a' && respA != 'b' && respA != 'c' && respA != 'd' && respA != 'e');
                            if (respA == gabP[i]){                          
                            notaA++;
                            nota[j]=notaA;
                            }
                    }   


                    }
                    printf("Nota aluno %d: %d\n", gabP[i], nota[j]);
                    printf("Tem mais um aluno? [s-sim, outro valor-nao]");
                    scanf(" %c", &continuar);

                }
                while (continuar == 's');

                return 0;
            }
  • You can put the solution to your question as an answer, accept it and leave it on record. Thus, all who find it useful, can give a vote for the question and answer...

1 answer

0


I managed to do, I put the new vector after the question loop....

#include <stdio.h>
    #define QUANT 10
    #define estudantes 20

    int main()
    {
        char gabP[QUANT];
        int resultado[estudantes];
        int i;
        char respA;
        char continuar;
        int nota;
        int alunos=20;
        int j;

        printf("Digite o gabarito da prova:\n");
        for(i = 0; i < QUANT; i++)
        {
            do
            {
                printf("Questao %d:", i + 1);
                scanf(" %c", &gabP[i]);
            } while(gabP[i] != 'a' && gabP[i] != 'b' && gabP[i] != 'c' && gabP[i] != 'd' && gabP[i] != 'e');
        }


        do
        {
            for (j=0;j<alunos; j++){
            nota = 0;
            printf("Digite as respostas do <Aluno %d>\n", j + 1);


            for(i = 0; i < QUANT; i++)
            {
                do
                {   printf("Questao %d:\n", i + 1);
                    scanf(" %c", &respA);

                }
                while (respA != 'a' && respA != 'b' && respA != 'c' && respA != 'd' && respA != 'e');
                    if (respA == gabP[i]){
                        nota++;

                    }

            } resultado[j]=nota;
                }
            for (j=0; j<alunos; j++){
            printf("NOTA = %d\n", resultado[j]);}
            printf("Tem mais um aluno? [s-sim, outro valor-nao]");
            scanf(" %c", &continuar);

        }
        while (continuar == 's');

        return 0;
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.