Dec 13, 2019, 03:37 AM

News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!


Program on reverse a number and test whether it is palindrome or not

Started by thiruvasagamani, Sep 22, 2008, 05:29 PM

previous topic - next topic
Go Down

thiruvasagamani

Write a program on reverse a number and test whether it is palindrome or not

l
Code: [Select]
ong reverse( long n)
{
long sum = 0;
int rem;
while( n > 0)
{
rem = n% 10;
sum = sum * 10 + rem; // multiply sum by 10 and add remainder
n = n / 10;
}
return ( sum );
}
char * palin( long n)
{
long reverse( long );
if( n == reverse( n )) // if the given number and reverse number are equal , 'n' is palind'me
return( " palin");
else
return( " not palindrome");
}

main()
{
long n , reverse( long);
char * palin( long);
printf( " enter any number");
scanf("%d",&n);
printf( " reverse number is %ld", reverse( n));
printf(" %s", palin( n));
getch();
}


o/p:
If you enter 'n' value as 101 the output is reverse is 101 and palindrome

Find sum of the digits repeatedly until we get single digit number that is
i. 199 want to become as 1
ii. 30006 want to become as 9
iii. 3456 want to become as 9
iv. 32567 want to become as 5

Code: [Select]
#include <stdio.h>
#include <conio.h>
int single-digit( int n)
{
if( n % 9 == 0)
return (9); // if 'n' is divisible by'9' return '9' itself
else
return ( n % 9); // if 'n' is not divisible by '9' return n% 9
}

main()
{
int n, single-digit(int);
printf(" enter any number");
scanf("%d", &x);
printf(" single digit is %d", single-digit ( x));
getch();
}

o/p:

if you enter 'x' value as 199 output is 1
Thiruvasakamani Karnan


pradeep prem

i have solve this program in college days it easy to get result

pasertkaeoub

like

คาสิโนออนไลน์ ในรูปแบบใหม่ล่าสุดจาก ปอยเปต คาสิโน รีสอร์ท ได้ที่นี่ royal1688

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Design Chennai | GinGly :: Mobile SMS Backup | CineBuzz :: Latest Cinema News | My Kids Diary :: Kids magical moment :: Book domain name @ 99 Rs monthly
Copyright 2005 - 2019 :: IT Acumens :: All Rights Reserved.
ITAcumens Forum with 2 lakhs post running for 14 years - Powered by IT Acumens Dedicated Server