Skip to main content

Checking whether a number is Palindrome.

PROCEDURE:-
    1.input an integer value n
    2.set sum to 0
    3.repeat steps 4 to 6 until n is greater than 0
    4. find n modulo 10 and assign it to r
    5.set sum=sum*10+r
    6.new value of n is equal to n/10
    7.if n and sum values are equal then print n is palindrome
    8.else print n is not palindrome
CODE:-

#include<stdio.h>
void main()
{
int n,r,s=0,m;
printf(“enter value for n”);
scanf(“%d”,&n);
m=n;
while(n>0)
{
    r=n%10;
    s=s*10+r;
    n=n/10;
}
if(s= =m)
printf(“ %d is a palindrome”,m);
else
printf(“%d is not a palindrome”,m);
}
Input:- enter value for n  121
Output:- 121 is a palindrome

Comments

Popular posts from this blog

Find Value of S=ut+1/2*a*t**2.

PROCEDURE:-        1.enter values for u,a,t to find distance        2.find distance with the formulae ut+1/2at 2        3.print the above result CODE:- #include<stdio.h> #include<conio.h> void main() {   float u,t,a,S;   clrscr();   printf(“enter values u,t,a”);   scanf(“%f %f %f”, &u,&t,&a);   S=(u*t)+(0.5*a*t*t);   printf(“\n  S = %f”, S); } Input:- enter values u,t,a               U=10,t=4,a=4.9 Output:- S =79.200