Header Ads

Header ADS

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

Program Code

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


Input


Output

 

No comments

Powered by Blogger.