Monday, 10 November 2014

Product of first n natural numbers

program to find product of first n natural numbers.


#include <iostream.h>
int main()
{
int n;
int i=1,prod=1;
cout<<“enter range:”;
cin>>n;
while(i<=n)
{
prod=i*prod;
i++;
}
cout<<“sum is:”<<prod;
return 0;
}

No comments:

Post a Comment