1055 - Tejasvi Borole FP Assignement-4
1055 - Tejasvi Borole FP Assignement-4
1055 - Tejasvi Borole FP Assignement-4
Date of Performance:06/06/2022
2)Objectives:
1)To understand and develop C program.
2)To understand concept of editor and compiler.
3)To understand different components of a basic C program.
4)To understand Concept Of operators.
3)Alogarithm:
Step 1:START the program.
Step 2:Declare the function fact(int num).
Step 3:Ask the user to enter the an integer to find the factorial.
Step 4:Read the integer and store it in num1.
Step 5: By using if else we derived many condition and then if num1 is
0 then factorial is 1 and else if num1 is less than 0 then invalid data &
else execute the code .
Step 6:Call the function fact in loop and print factorial of num.
Step 7:Define the function and its operation in function fact and return
the value of fact .
Step 8:Display the value of fact.
Step 9:STOP the program.
4)Flowchart:
START
NO No
Else if If Else
Num1 Num1==0 num1>0
<0
YES YES
YES
Return Num*fact(num-1)
Num=num+1
Display factorial
5)Program:
#include<stdio.h> STOP
long int fact(int num);
int main()
{
long int num1,factorial;
printf("Enter the number:\n");
scanf("%ld",&num1);
factorial=fact(num1);
printf("The factorial of %ld is %ld",num1,factorial);
return 0;
}