Canna

Tuesday, 25 September 2018

Push Ups withBlaze

  • Problem Description

    At UAB football games, Blaze does push ups after each Blazer score. After the first Blazer touchdown (and point after), Blaze does 7 push ups. After the second touchdown and point after, the score is now 14 and Blaze does 14 push ups.

    Write a program that calculates how many total push ups Blaze does during the whole game. Assume that only 7 point touchdowns (including the point after) occur. Prompt for the final score and print out how many push ups Blaze has done.
  • Test Case 1

    Input (stdin)
    21
    
    
    Expected Output
    42
  • Test Case 2

    Input (stdin)
    28
    
    
    Expected Output
    70
  • Program
  • #include <stdio.h>
    int main()
    {
       int a,b,i;
      scanf("%d",&a);
      for(i=7;i<=a;i=i+7)
        b=b+i;
      printf("%d",b);
        
     return 0;
    }

No comments:

Post a Comment

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