answersLogoWhite

0


Best Answer

include<stdio.h>

main()

{

int n,fact=1;

clrscr();

printf("enter a no");

scanf("%d",&n);

while(n>0)

{

fact=fact*n;

n--;

}

printf("the factorial of given no is %d",fact);

getch();

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

int n, f=1;

printf("Enter a number= ");

scanf(%d,&n);

while(n>1)

{

f=f*n;

n--;

}

printf("Factorial of number %d is %d",n,f);

}

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

#! /usr/bin/env ruby

def fac(n)

return 1 if n<=1

return n * fac(n-1)

end

puts fac(gets.to_i)

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

int fact (int n) {

if (n==0) return 1;

return n* fact(n-1);

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: 2 Write an algorithm to print the factorial of a given number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write an algorithm to print the factorial of given number and then draw the flowchart?

write an algorithm to print the factorial of a given number and then draw the flowchart. This looks like someones homework, defiantly someone looking for the easy way. When it comes to programming, the more you do the better you get. Experience counts (making your own mistakes and learning from the mistake).


A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string


Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position?

please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.


Programming to calculate a factorial number?

double factorial(double N){double total = 1;while (N > 1){total *= N;N--;}return total; // We are returning the value in variable title total//return factorial;}int main(){double myNumber = 0;cout > myNumber;cout


How do you write an algorithm to find the number of times a given ITEM occurs in LIST?

You can write any algorithm in any way you like. Many prefer pseudocode or flowcharts, others use prose or more formalized methods. For example, if you wanted to describe an algorithm to count the number of occurrences of a given item I in a given list L, I would propose the following pseudocode: let counter be 0. let the current item C be the first item in list L. while C == valid { if C matches I then increment counter set C to the next item in the list } return counter.

Related questions

Write an algorithm to print the factorial of given number and then draw the flowchart?

write an algorithm to print the factorial of a given number and then draw the flowchart. This looks like someones homework, defiantly someone looking for the easy way. When it comes to programming, the more you do the better you get. Experience counts (making your own mistakes and learning from the mistake).


A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Write a php scrpit to implement factorial of a given number?

for($rval = $n = intval($_GET['number']); $n > 2; $n--) $rval *= $n - 1;echo $rval;


How do you find factorial of given number?

Factorials are the product of 1 and all the integers up to the given number. Simply put, 5 factorial or 5! = 5*4*3*2*1


Find flow chart for factorial of given number?

i need a pic of cuson


Program for finding the factorial of the two given number using constructor?

kjhk


Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position?

please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.


Programming to calculate a factorial number?

double factorial(double N){double total = 1;while (N > 1){total *= N;N--;}return total; // We are returning the value in variable title total//return factorial;}int main(){double myNumber = 0;cout > myNumber;cout


How many keywords are there in c?

answer:32 programme to print factorial of a given number in c languages


What is a Flow chart for finding factorial of a given number using recursion function?

no answer....pls post


How many diagonals do hexagons have?

The number of diagonals in an n-sided polygon is given by nC2 - n (where n is the number of sides of the polygon) or in the expanded form: factorial (n) _______________________ {factorial (2) * factorial (n-2)} substituting (n = 6) for a hexagon we get the number of diagonals as 9. Similarly, substituting (n=5) for a pentagon we get the number of diagonals as 5.