Thursday, 26 May 2016

Passing Array Through Function And Return Value To Main In C++ Code


Passing Array Through Function And Return Value To Main In C++ Code

















#include<iostream>
using namespace std;
int fact(int);

int main()
{
int result;
int a;
cout<<"Enter Value =";
cin>>a;
result=fact(a);
cout<<"Factorial ="<<result<<endl;
}
int fact(int a)
{
int fact=1;
for(int i=1; i<=a; i++)
{
fact=fact*i;
}
return fact;
}

No comments: