Monday, September 17, 2018

Big Buddy

  • Problem Description

    Princess Rupsa saw one of her friends playing a special game. Her friend gave a bag that has a set of stones with different weighs. Se is assigned with a task to add the weighs and also find the average weight of the bag.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a,i;
      float arr[100],count=0;
      scanf("%d",&a);
      for(i=0;i<a;i++)
      {
        scanf("%f",&arr[i]);
        count+=arr[i];
      }
      printf("%.1f\n",count);
      printf("%.1f",count/a);

    return 0;
    }
  • Test Case 1

    Input (stdin)
    3
    
    2.0 4.0 5.0
    
    
    Expected Output
    11.0
    
    3.7
  • Test Case 2

    Input (stdin)
    3
    
    4.0 2.0 15.0
    
    
    Expected Output
    21.0
    
    7.0

No comments:

Post a Comment