Wednesday, 6 April 2016

write a program in c++ to find product of n natural no's using do while loop.

//wap in c++ to find product of n natural no's using do while loop.

Coding:-

#include<iostream.h>
#include<conio.h>

void main()
{

int i=1,n,prod=1;
cout<<"enter the no";
cin>>n;
do{
prod=prod*i;
i++;
}
while(i<=n);
cout<<"product="<<prod;
getch();
}
Output:-

 

No comments:

Post a Comment