Product of odd integers in given range
C Program that calculates and prints the product of the odd integers in given range.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int i, low, high, prod=1;
printf("Enter lower limit: ");
scanf("%d", &low);
printf("Enter upper limit: ");
scanf("%d", &high);
for(i=low; i<=high; i++)
{
if(i % 2 != 0)
{
prod *= i;
}
}
printf("Product of odd numbers in the range (%d-%d) = %d", low, high, prod);
getch();
}
Output
Enter lower limit: 5
Enter upper limit: 12
Product of odd numbers in the range (5-12) = 3465