Advertisement
Anik_Akash

Several Scores with Validation

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