Skip to content

Commit

Permalink
Merge pull request tarunsinghofficial#736 from sidverr/main
Browse files Browse the repository at this point in the history
Palindrome
  • Loading branch information
tarunsinghofficial committed Oct 22, 2020
2 parents 4e6b387 + 6eefdbe commit 6893d07
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions C Program/palindrome.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include<stdio.h>

// declaring the recursive function
int isPal(int );

/*
global declaration to use the same value
in both the functions
*/
int n;

int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int palindrome;
printf("\n\nEnter a number to check for Palindrome: ");
scanf("%d", &n);
palindrome = isPal(n);
if(palindrome == 1)
printf("\n\n\n%d is palindrome\n\n", n);
else
printf("\n\n\n%d is not palindrome\n\n", n);

printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}

int isPal(int aj)
{
static int sum = 0;
if(aj != 0)
{
sum = sum *10 + aj%10;
isPal(aj/10); // recursive call same as while(n!=0) using loop
}
else if(sum == n)
return 1;
else
return 0;
}
4 changes: 4 additions & 0 deletions Siddharth-Verma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Siddharth Verma
Photo - https://d1kkg0o175tdyf.cloudfront.net/large/s_411d1093b98c-2019-09-26-20-30-25-000640.jpg
Location : India
Github: https://github.com/sidverr

0 comments on commit 6893d07

Please sign in to comment.