Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
1.00/5 (7 votes)
See more:
How to make wrapper function run with 3 copy of factorial function and show the result in any language?

Use the factorial function in wrapper program 3 time then show result >

C#
#include<iostream.h>
#include<stdlib.h>
int t=0;
int factorial1(int num)
{
    int f=1;
    for(int i=1;i<=num;i++)
    {
    
        f=f*i;
    
    }

    int x=1+rand()*10;
    
    if(x==num)
        return f+1+rand()*100;
    else
        return f;
}

int factorial2(int n)
{
    //int i=0,fact=1,x;
    if(n<=1)
    {
        double x= rand() * 10 + 1;
        if (x == 5)
            return rand() * 100;
        else
             return 1;
    }
    else
        return n*factorial2(n-1);
}

double factorial3(int num)
{
    double f=1;
    
    for(int i=1;i<=num;i++)
    {
        f=f*i;
    }
    
    int x=(rand()%10)+1;
    int t = 0;
    
    if(x==num && t==0)
    {
        return f+rand()%100;
    
        //t=1;
    }
    else
        return f;
}

main()
{
//cout<<"please enter a number:";
//int z;
//cin>>z;

    for (int i=1; i<=10; i++)
    {
        cout<<"Factorial of "<<i<<":"<<endl<<endl;
    
        cout<<"Model1"<<" : "<<factorial1(i)<<endl;
    
        cout<<"Model2"<<" : "<<factorial2(i)<<endl;
    
        cout<<"Model3"<<" : "<<factorial3(i)<<endl<<endl;
    
    }
    
}


Just make wrapper to run this code.
Posted
Updated 11-Dec-14 2:59am
v3
Comments
Sergey Alexandrovich Kryukov 1-Dec-14 13:57pm    
What are you even talking about? Please explain everything properly, in detail.
—SA
Member 11277888 1-Dec-14 14:11pm    
just make wrapper run factorial function 3 times and show the result .
Tomas Takac 1-Dec-14 14:16pm    
This doesn't explain it really. Maybe you should post some code to illustrate the problem.
Member 11277888 1-Dec-14 14:23pm    
[Code removed — SA]
Tomas Takac 1-Dec-14 14:25pm    
Please update your question via "improve question", do not post additional information in comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900