Header Ads

Header ADS

Solution of URI 1117::Score Validation

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.




#include <stdio.h>
int main() {
    float num,avg,sum=0;
    int count=0;

    while(scanf("%f",&num) !=EOF) {
        if(num>=0.0 && num<=10.0) {
            count++;
            sum += num;
        }

        else {
            printf("nota invalida\n");
        }

        if(count==2) {
            avg=sum/2.0;
            printf("media = %.2f\n",avg);
            return 0;
        }
    }

    return 0;
}

No comments

Theme images by konradlew. Powered by Blogger.