Factorial Number: AIM:-To Write A Program To Calculate The Factorial of The Given Number Using Functions. Algorithm
Factorial Number: AIM:-To Write A Program To Calculate The Factorial of The Given Number Using Functions. Algorithm
No:5a
FACTORIAL NUMBER
AIM:To write a program to calculate the factorial of the given number using functions.
ALGORITHM:
STEP 1: Start the program.
STEP 2: Enter a number.
STEP 3: Set a loop to find the factorial of the given no using Fact=fact*i
STEP 4: Print the factorial of the given number.
STEP 5: Stop the program.
Start
Read n
i1
Is i<=n
No
Yes
Fact=fact*i
I=i+1
PROGRAM:
Print fact
Stop
Thus the C program to calculate factorial of the given number using function is
Calculated successfully and verified.
Ex. No: 5b
AIM:To write a C program to find the reverse of digits and Check whether the number is
Palindrome or not
ALGORITHM:STEP 1: Start the program.
STEP 2: Enter the number.
STEP 3: Set a loop upto the number is not equal to zero .
Remnum%10
STEP 4: After the end of the loop print the reverse of the number.
STEP 5: Find whether the reverse no is equal to the actual given number to
check if it is a palindrome.
STEP 6: Stop the Program.
Start
Read num
A=num; rnum=0
No
Is i<num
Yes
fib=fib+a; Remnum%10
+rem Nu
Print rnum
Is a==r num
m num/10
Yes
Print Palindrome
Stop
No
Print it is not
Palindrome
PROGRAM:
// REVERSE, PALINDROME
#include<stdio.h>
#include<conio.h>
void main()
{
int a,num,sum=0,rnum=0,rem;
clrscr();
printf("\n Enter the No:");
scanf("%d",&num);
a=num;
while(num!=0)
{
rem=num%10;
rnum=rnum*10+rem;
num=num/10;
}
printf("\n The Reverse %ld is=%ld\n",a,rnum);
if(a==rnum)
printf("\n The Given number is a Palindrome");
else
printf("\n The Given number is not a Palindrome");
getch();
}
OUTPUT:Enter the No:12345
The Reverse 12345 is=54321
The Given number is not a Palindrome
RESULT:Thus the C program to find the reverse of digits and Check whether it is
a Palindrome or not is verified successfully.