Showing posts with label palindrome. Show all posts
Showing posts with label palindrome. Show all posts

Saturday, September 27, 2014

Largest Palindrome of 3 Numbers

If you have any doubts, let me know
#include <stdio.h>
#include <string.h>
#include<limits.h>

main()
{
    int i=999,j=999,sum=0,r=0,y,x,sum1=0,a[3000],k=0,temp;
    for(i=999;i>100;i--)
    {
        for(j=999;j>100;j--)
        {
            sum=i*j;
            x=sum;
            while(sum>0)
            {
             sum1=sum1*10;
             sum1=sum1+sum%10;
             sum=sum/10;
            }
            if(sum1==x)
         {
             a[k]=x;
             k++;
         }
            sum1=0;
        }
    }
   
    for(i=0;i<k;i++)
    for(j=0;j<k;j++)
    {
        if(a[i]<a[j])
        {
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }
printf("%d",a[k-1]);

}

Saturday, August 9, 2014

Program to check whether a number is a palindrome.

Program to find if a number is a palindrome. One of the most basic programs for any CSE student to learn. Comment below if you need help

#include<stdio.h>
void main()
{
int x,num,sum=0,rem;
printf("enter the number");
scanf("%d",&num);
x=num;
while(num>0)
{
rem=num%10;
sum=(sum*10)+rem;
num=num/10;
}
if(sum==x)
printf("palindrome");
else
printf("no");
}