Skip to main content

Palindrome of a given number using C

#include<stdio.h>
#include<conio.h>

void main()
{
   long n, r, ri=0, oi;

   clrscr();
   printf("\nEnter a number: ");
   scanf("%ld",&n);

   oi = n;
   while(oi!=0)
   {
      ri = ri * 10;
      ri = ri + oi % 10;
      oi = oi / 10;
   }
   if(n==ri)
   {
      printf("\nThe given number is a Palindrome");
   }
   else
   {
      printf("\nThe given number is not a palindrome");
   }
   getch();
}

Output:

Enter a number: 1221
The given number is a Palindrome


Output:

Enter a number: 953212359
The given number is a Palindrome

Comments

Popular posts from this blog

Creating a Realtime Clock using Python program

Clock from turtle import * from datetime import datetime def jump(distanz, winkel=0):     penup()     right(winkel)     forward(distanz)     left(winkel)     pendown() def hand(laenge, spitze):     fd(laenge*1.15)     rt(90)     fd(spitze/2.0)     lt(120)     fd(spitze)     lt(120)     fd(spitze)     lt(120)     fd(spitze/2.0) def make_hand_shape(name, laenge, spitze):     reset()     jump(-laenge*0.15)     begin_poly()     hand(laenge, spitze)     end_poly()     hand_form = get_poly()     register_shape(name, hand_form) def clockface(radius):     reset()     pensize(7)     for i in range(60):         jump(radius)         if i % 5 == 0:           ...

Star Design using Python program

Star Design import turtle turObj = turtle.Turtle() turObj.getscreen().bgcolor("#555555") turObj.speed(10) def star(turtle, size):     if size <=10:         return     else:         for i in range(30):             turObj.color("#FEACFF")             turObj.forward(i * 15)             turObj.right(144)            star(turObj,100)        turtle.done() Output:

Program to find the given string is a Palindrome or not using C

/*Program to find the given string is a Palindrome or not */ #include<stdio.h> #include<conio.h> #include<string.h> void main() {    char a[15];    int i, len, count=0;    clrscr();    printf("\nEnter a string: ");    scanf("%s", a);    len=strlen(a);    for(i=0; i<len; i++)    {       if(a[i]==a[len-i-1])       count=count+1;    }    if(count==len)    {      printf("\nThe given string is a Palindrome");    }    else    {      printf("\nThe  given string is not a Palindrome");    }    getch(); } OUTPUT: Enter a string:  hannah The given string is a Palindrome Enter a string:  welcome The given string is not a Palindrome