Friday, 18 March 2016

Solution of URI 1117 :: Score Validation


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    double a,b,c=0,d=0;
    while(1)
    {
        if(d==2)
            break;
        scanf("%lf", &a);
        if(a>=0 && a<=10)
        {
            d++;
            c+=a;
        }
        else
            printf("nota invalida\n");
    }
    b=c/2.00;
    printf("media = %.2lf\n", b);
    return 0;
}

6 comments:

  1. You should be use Comment in your code

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. #include
    main()
    {
    float a, b, c;

    scanf("%f", &a);
    while(a<0 || a>10){
    printf("nota invalida\n");
    scanf("%f", &a);
    }
    scanf("%f", &b);
    while(b<0 || b>10){
    printf("nota invalida\n");
    scanf("%f", &b);
    }
    c=(a+b)/2;
    printf("media = %.2f\n", c);
    }

    ReplyDelete
  4. #include
    int main()
    {
    float a,b;

    while(1)
    {
    scanf("%f",&a);
    if(a<0 || a>10)
    printf("nota invalida\n");
    else
    break;
    }
    while(1)
    {
    scanf("%f",&b);
    if(b<0 || b>10)
    printf("nota invalida\n");
    else
    break;
    }
    printf("media = %.2f\n",(a+b)/2);

    return 0;
    }

    ReplyDelete
    Replies
    1. amazing way of thinking \and this source code is much esier to underestand

      Delete
    2. #include
      using namespace std;

      int main(){
      float X,Y;
      int count = 0;

      while(true){
      if(count == 0){
      cin >> X;

      if(X >= 0.0 && X <= 10.0){
      count = 1;
      }else{
      cout<<"nota invalida"<> Y;

      if(Y >= 0.0 && Y <= 10.0){
      printf("media = %.2f\n",(X+Y)/2);
      break;
      }else{
      cout<<"nota invalida"<<endl;
      }
      }
      }
      }

      Delete

Note: only a member of this blog may post a comment.