/*
* Purpose : Calculate the factorial of a number
* Inputs : int x -- the number of interest
* Outputs : x! if x is non-negative, -1 otherwise
*/
int factorial (int x)
{
int x_factorial = x;
if (x > 0)
{
while (x > 1)
{
x_factorial *= --x;
}
return x_factorial;
}
else if (x = 0)
return 1;
else
return -1;
}
/*
* Purpose : Calculate the binomial coefficient nCr
* Inputs : int n -- the set size
* int r -- how many to choose
* Outputs : The binomial coefficient nCr if r is valid, -1 otherwise
*/
int nCr (int n, int r)
{
if (r >= 0 && n >= r)
return factorial(n) / (factorial(r) * factorial(n - r));
else
return -1;
}
Here is an example program: class obj{ public: float p,n,r,si; friend void calc( obj temp); }; void calc( obj temp){ si = (p*n*r)/100; } The initialization and function calling is essential.
If it contains a decimal point or an exponential part, then it should be handled as a float (or double).You can determine an existing variable's type in C using the type() function
write a vb program to find the magic square
The function of the RAC recovery program is to find over payments and under payments in the Unites States health care industry to improve the budget issues and efficiency.
Write a program to find the grade obtained by the students of a class
There will be a function in it like this: double RectangleArea (double a, double b) { return a*b; }
The number of function is Geometry
You use the inverse function (if one exists).So, if y = f(x) then x = f-1(y)
int square (int N) return N*N;
You can use the MIN function or you can use the SMALL function, using 1 as the second argument in it. So to find the lowest value in the cells from A2 to A16 the function choices are: =MIN(A2:A16) =SMALL(A2:A16,1) MIN would be more commonly used for the lowest value, but using SMALL you can get the second smallest by changing the 1 to 2, or the third lowest by using 3 and so on.
The IF function checks a condition to determine a task to do. It is a logical function. VLOOKUP is a lookup function. It can search through a list to find a value or a position in a range, and then find a corresponding value. There are situations where both could be used. Sometimes a VLOOKUP is good for using in place of a nested IF that is having to search through a lot of options. See the related questions below.
If it is a differentiable function, you find the value at which its derivative is 0. But in general, you can plot it as a line graph and see where it peaks.
program to find maximum of two numbers using pointers
Here is an example program: class obj{ public: float p,n,r,si; friend void calc( obj temp); }; void calc( obj temp){ si = (p*n*r)/100; } The initialization and function calling is essential.
To find the value of the other variable
I suggest: - Take the derivative of the function - Find its initial value, which could be done with the initial value theorem That value is the slope of the original function.
The y-intercept is the value of a function f when x is equal to zero. So, substitute 0 for x into the equation and find the value of y.