In: Computer Science
Write a C++ program to calculate and print the product of odd integers and even integers of the first ānā natural numbers .
thanks for the question, here is the complete program in C++
=====================================================================
#include <iostream>
using namespace std;
int main(){
unsigned long long int oddProduct=1, evenProduct=1;
int n;
// prompt user to enter the value of n
cout<<"Enter the value n: ";
cin>>n;
// loop from 2 to n
for(int num=2; num<=n; num++){
if(num%2==1) oddProduct*=num;
else evenProduct*=num;
}
cout<<"Product of odd integers: "<<oddProduct<<endl;
cout<<"Product of even integers: "<<evenProduct<<endl;
}
=====================================================================
