Tuesday, 26 January 2016

Solution of URI 1040 :: Average 3


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    double N1, N2, N3, N4, N5, a,b;
    scanf ("%lf%lf%lf%lf", &N1,&N2,&N3,&N4);
    a=((N1*2)+(N2*3)+(N3*4)+N4)/10;
    printf ("Media: %.1lf\n",a);
    if(a>=7)
        printf ("Aluno aprovado.\n");
    else if(a<5)
        printf("Aluno reprovado.\n");
    else if(a>=5&&a<=6.9)
    {
        printf ("Aluno em exame.\n");
        scanf("%lf", &N5);
        printf ("Nota do exame: %.1lf\n",N5);
        b=(N5+a)/2;
        if(b>=5)
            printf ("Aluno aprovado.\n");
        else if(b<=4.9)
            printf ("Aluno reprovado.\n");
        printf ("Media final: %.1lf\n",b);
    }
    return 0;
}

2 comments:

  1. a=((N1*2)+(N2*3)+(N3*4)+N4)/10;

    why divided by 10 bro?

    ReplyDelete
  2. 10 is the sum of the weights (2+3+4+1).

    ReplyDelete

Note: only a member of this blog may post a comment.