**The Program in C that finds the sum,average of values appearing at the positions divisible by 3 in the given sequence of n values is given below:**

```
#include <stdio.h>
int main() {
int n, i, sum = 0, count = 0;
double average;
printf("Enter the number of elements in the sequence: ");
scanf("%d", &n);
for (i = 0; i < n; i++) {
int x;
printf("Enter the next element of the sequence: ");
scanf("%d", &x);
if ((i+1) % 3 == 0) {
sum += x;
count++;
}
}
if (count != 0) {
average = (double) sum / count;
printf("Sum of the values appearing at positions divisible by 3: %d\n", sum);
printf("Average of the values appearing at positions divisible by 3: %lf\n", average);
} else {
printf("No value found at positions divisible by 3\n");
}
return 0;
}
```

## Output:

Enter the number of elements in the sequence: 7

Enter the next element of the sequence: 12

Enter the next element of the sequence: 56

Enter the next element of the sequence: 33

Enter the next element of the sequence: 57

Enter the next element of the sequence: 78

Enter the next element of the sequence: 11

Enter the next element of the sequence: 10

Sum of the values appearing at positions divisible by 3: 44

Average of the values appearing at positions divisible by 3: 22.000000

## Pro-Tips**💡**

This program prompts the user to enter the number of elements in a sequence, then uses a for loop to iterate through the sequence.

Inside the for loop, it reads each element, check if its position is divisible by 3 and if yes, adds that value to the sum and increases the count.

After the loop it checks if count is zero, if yes it means no value found at positions divisible by 3, otherwise it calculates the average by dividing the sum with the count of values at positions divisible by 3 and prints the sum and average.

It is worth noting that in this program I am using i+1 as position, as the positions in array starts from 0 in C.

**Learn C-Sharp ↗**

C-sharp covers every topic to learn about C-Sharp thoroughly.

**Learn C Programming ↗**

C-Programming covers every topic to learn about C-Sharp thoroughly.

**Learn C++ Programming↗**

**Learn C++ Programming↗**

C++ covers every topic to learn about C-Sharp thoroughly.