Friday, 16 November 2012

Product of integers upto given limit.


/* if you give the integer to which you want to get product greater than 9 then it will generate output in Exponential form. if u make product and end_num integer then it will not generate answer greater than integer  value limits. */
#include <iostream>
using namespace std;
int main()
{
double product=1,end_num;
cout << "Enter integer for which u want to get Product: ";
cin >> end_num;
for (int i=1;i<=end_num;i++)
product=product*i;
cout << "Integer Product of 1 to "<< end_num << " is= " << product <<endl;
return 0;
}

No comments:

Post a Comment