In: Computer Science
// Screenshot of the code
// Sample output
// code to copy
/**
* C program to print sum of all even numbers between 1 to 30
*/
#include <stdio.h>
int main()
{
// declare and initialize variables
int i,n,thirtysum;
n=30;
thirtysum=0;
for(i=2; i<n; i+=2)
{
if(i%2==0){
/* Add current even number to sum */
thirtysum += i;
}
}
printf("The Sum of all even number between 1 to %d = %d", n,
thirtysum);
return 0;
}