Saturday, August 18, 2018

SUM OF 6 NUMBERS

  • Problem Description

    Print the sum of 6 numbers using array and pointers
  • CODING ARENA::
  • #include <stdio.h>
    int main()
    {
      int a,sum=0,i;
      for(i=0;i<6;i++)
      {
        scanf("%d",&a);
        sum=sum+a;
      }
      printf("%d",sum);

    return 0;
    }
  • Test Case 1

    Input (stdin)
    1 2 3 4 5 6
    
    
    Expected Output
    21
  • Test Case 2

    Input (stdin)
    1 1 1 2 2 2
    
    
    Expected Output
    9

No comments:

Post a Comment