Advertisement
PROFESSOR_AIH

Several Scores with Validation

Apr 7th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int j=0,x;
  5.     double n,avg,arr[2];
  6.     while(1)
  7.     {
  8.         while(1)
  9.         {
  10.             scanf("%lf",&n);
  11.             if(n>=0 && n<=10)
  12.             {
  13.                 arr[j]=n;
  14.                 j++;
  15.             }
  16.             else
  17.                 printf("nota invalida\n");
  18.             if(j>1)
  19.                 break;
  20.         }
  21.         avg=(arr[0]+arr[1])/2;
  22.         printf("media = %.2lf\n",avg);
  23.         j=0;
  24.         avg=0;
  25.         arr[2]=0;
  26.         while(1)
  27.         {
  28.             scanf("%d",&x);
  29.             printf("novo calculo (1-sim 2-nao)\n");
  30.             if(x==1 || x==2)
  31.                 break;
  32.         }
  33.         if(x==1)
  34.             continue;
  35.         else
  36.             break;
  37.     }
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement