Header Ads

Header ADS

Write a C program that calculates and prints the sum and product of the Even integers from 1 to 30

Program Code 

#include<stdio.h>
int main(){
    int counter;
    int total=0;
    int multiplication=1;
    for(counter=2;counter<30;counter+=2){
        total+=counter;
        multiplication=multiplication*counter;
    }
printf("%d\n",total);
printf("%d\n",multiplication);
return 0;
}


Input 


Output
 

No comments

Powered by Blogger.