Write a program that reads in a positive integer N and calculates and displays the sum of the first N even integers. For example if N is 6, the program should display the value 42, which is: 2+4+6+8+10+12=42.
Caution: The program has to do the addition.
Question in C programming 2 answer quickly please?
int n;
int sum = 0;
scanf("%d",%26amp;n);
for ( int i = 1; i %26lt;= n; ++i){
sum += i*2;
}
printf(sum);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment