The sum of the first n even positive numbers can be calculated using the following formula:
sum = n * (n + 1)
Here is an example program to find the sum of the first n even positive numbers using the above formula:
#include <stdio.h>
int main() {
int n, sum;
printf("Enter the value of n: ");
scanf("%d", &n);
// calculate the sum using the formula
sum = n * (n + 1);
printf("The sum of the first %d even positive numbers is %d\n", n, sum);
return 0;
}
In this program, we first declare two integer variables n and sum. We ask the user to input the value of n using the scanf() function.
Then, we calculate the value of sum using the formula sum = n * (n + 1). Finally, we print the value of sum using the printf() function.