Friday, October 26, 2018

Uri 1040 solution in C | Average 3

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/

#include<stdio.h>
main()
{
    float n1,n2,n3,n4,m,t;
    scanf("%f%f%f%f",&n1,&n2,&n3,&n4);
    m=((n1*2)+(n2*3)+(n3*4)+(n4*1))/10;
    printf("Media: %.1f\n",m);
    if(m>=7)
    {
        printf("Aluno aprovado.\n");
    }
    else if(m<5)
    {
        printf("Aluno reprovado.\n");
    }
    else if(m>=5&&m<7)
    {
        printf("Aluno em exame.\n");
        float d,r;
        scanf("%f",&d);
        printf("Nota do exame: %.1f\n",d);
        r=(m+d)/2;
        if(r>=5)
        {
          printf("Aluno aprovado.\n");
        }
        else if(r<5)
        {
            printf("Aluno reprovado.\n");
        }
        printf("Media final: %.1f\n",r);
    }
    return 0;
}

 //Happy_Coding

No comments:

Post a Comment