URI Online Judge | 1117 Score Validation


Write a program that reads two scores of a student. Calculate and print the average of these scores. Your program must accept just valid scores [0..10]. Each score must be validated separately.



#include<stdio.h>

int main()
{
    float a,b,c,d,i;

    for(i=0;i<10;i++){
      scanf("%f",&a);
    if(a<0 || a>10){
      printf("nota invalida\n");
     }
    else{
        c=a;
        break;
    }
  }
    for(i=0;i<10;i++){
        scanf("%f",&b);
    if(b<0 || b>10){
        printf("nota invalida\n");
    }

    else{
        d=b;
         if(d>0 && c>0){
         printf("media = %.2f\n",(c+d)/2);
         break;

         }
    }
        }
    return 0;
}

Comments

Popular posts from this blog

Link3 FTP Server

কেন গবেষণা করব?

Arduino Adventures by Floyd Kelly James and Harold Timmis