Computer Science, asked by Anonymous, 10 months ago

hi✌️✌️

1)WAP to enter a number and print factorial of that number.

Answers

Answered by Anonymous
111

Answer:

#include<stdio.h>

int main(){

 int i,f=1,num;

 

 printf("Enter a number: ");

 scanf("%d",&num);

 

 for(i=1;i<=num;i++)

     f=f*i;

 

 printf("Factorial of %d is: %d",num,f);

 return 0;

}

Result:

Enter a number: For example 8

Factorial of 8 is: 40320

#Capricorn Answers

Answered by Bᴇʏᴏɴᴅᴇʀ
14

Answer:-

Factorial Program in JAVA for n numbers:-

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

\bf{import} java.util.Scanner;

class Factorial

{

\bf{public \: static \: void} main (String args [ ])

{

int n, c, f = 1;

System.out.println("Enter a number to Calculate the Factorial");

Scanner in = new Scanner (System.in);

n= in.nextInt( );

\bf{if}(n<0)

System.out.println("Number should be non-negative");

\bf{else}

{

\bf{for}(c =1; c <= n; c++)

f = f*c;

System.out.println("Factorial of "+n+" is = " +f);

}

}

}

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Factorial Program in PYTHON for n numbers:-

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

number = int(input("Enter a number to Calculate the Factorial:"))

fact = 1

for i in range (1, number + 1):

fact = fact*i

print("The Factorial of %d = %d %(number,fact))

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Similar questions