Question

In: Computer Science

compute and print factorial if it is equal to 6, not equal to 6, and square...

compute and print factorial if it is equal to 6,

not equal to 6,

and square of the factorial, if the input is equal to 6 ..... C programming

Solutions

Expert Solution

#include <stdio.h>

int factorial(int a); //function prototype to calculate factorial

int main(int argc, char *argv[]) {

int a,b;
printf("Enter input:\n");
scanf("%d",&a); //stores the input
b=factorial(a); //calculate factorial of input
  
printf("Factorial of %d is %d\n",a,b); //display factorial
if(a==6){
   printf("Square of factorial of %d is %d\n",a,b*b); //if input is 6 then display square of factorial also
}
  
return 0;


}

//function to calculate factorial
int factorial(int a){
   if(a==0){
       return 1;
   }else{
       return a*factorial(a-1);
   }
}


Related Solutions

Compute the mean square error using equation s2 = MSE =
Consider the data. xi 1 2 3 4 5 yi 4 8 6 12 14 (a) Compute the mean square error using equation  s2 = MSE = SSE n − 2  . (Round your answer to two decimal places.) (b) Compute the standard error of the estimate using equation s = MSE = SSE n − 2  . (Round your answer to three decimal places.) (c) Compute the estimated standard deviation of b1 using equation sb1 = s Σ(xi −...
(a) Compute the mean square error using equation s2 = MSE =
Consider the data. xi 1 2 3 4 5 yi 4 6 5 12 13 (a) Compute the mean square error using equation s2 = MSE = SSE n − 2  . (Round your answer to two decimal places.) (b) Compute the standard error of the estimate using equation s =MSE= SSE n − 2 =  . (Round your answer to three decimal places.) (c) Compute the estimated standard deviation of b1 using equation sb1 = s Σ(xi − x)2...
Please explain why. Note that Latin square designs are equivalent to specific fractional factorial designs (e.g.,...
Please explain why. Note that Latin square designs are equivalent to specific fractional factorial designs (e.g., the 4x4 Latin square design is equivalent to a 43-1fractional factorial design). Please explain why.
Two diagonals of a rhombus are equal. Is it a square? Justify your answer.
Two diagonals of a rhombus are equal. Is it a square? Justify your answer.
Statement: For a given integer N, print all the squares of positive integers where the square...
Statement: For a given integer N, print all the squares of positive integers where the square is less than or equal to N, in ascending order. Programming Tasks: Prompt the user to input the value of N Output to the screen all squares of positive integers <= N Tests: Item Test 1 Test 2 Test 3 Inputs: 50 9 100 Outputs: 1 4 9 16 25 36 49 1 4 9 1 4 9 16 25 36 49 64 81...
What is Factorial Experiment Types of Factorial Experiment Uses of Factorial Experiment in research Example of...
What is Factorial Experiment Types of Factorial Experiment Uses of Factorial Experiment in research Example of Each types of Factorial Experiment Conclusion Reference
The standard deviation is equal to the square root of the average squared deviations about the...
The standard deviation is equal to the square root of the average squared deviations about the mean. More succintly, it is equal to the square root of the variance. So one way to calculate the standard deviation of a frequency distribution is to calculate the variance. Complete the table below as the first step in calculating the variance: (10 points) X f X−x (X−x)2 96 1 94 1 92 1 87 1 85 1 84 1 83 1 82 1...
(a) Compute the first-order correction to all energy eigenvalues of a particle in a square well...
(a) Compute the first-order correction to all energy eigenvalues of a particle in a square well in the region 0 ≤ ? ≤ L with added potential: ?(?) = ?o? when 0 ≤ ? ≤ L/2 and ?o (L − ?) when L/2 ≤ ? ≤ L. (b) Using the given potential, use the variational theorem to compute an upper bound to the ground state using the trial function below ∅(?) = ?1 (2/L)1/2 sin ( ??/L ) + ?2...
Your assignment is to compute how big a square solar collector would have to be in...
Your assignment is to compute how big a square solar collector would have to be in order to provide power to (1)       all the residents of the UAE (2)        all the people of the world. The power supplied should be equal to the current per capita consumption of the UAE. Assume that all the energy is to be supplied in the form of electricity. In this assignment, you must specify the sources of all data you used in order to compute your...
Is ‘equal pay for equal work’ identical to ‘pay equity’? Explain. 6 MARKS
Is ‘equal pay for equal work’ identical to ‘pay equity’? Explain. 6 MARKS
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT