SUM OF 6 NUMBERS

Description:

Print the sum of 6 numbers using array and pointers 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

Program :

#include<stdio.h>

int main() {

   int numArray[10];

   int i, sum = 0;

   int *ptr;

 

   for (i = 0; i < 10; i++)

      scanf("%d", &numArray[i]);

 

   ptr = numArray;

 

   for (i = 0; i < 6; i++) {

      sum = sum + *ptr;

      ptr++;

   }

 

   printf("%d", sum);

  return 0;

}