#include <stdio.h>
#include <conio.h>
void main()
{
int n, a, r=0;
clrscr();
printf(" Enter any number to get its reverse: ");
scanf("%d",& n);
while(n> =1)
{
a = n % 10;
r = r * 10 + a;
n = n / 10;
}
printf(" Reverse = %d",r);
getch();
}
OUTPUT:
Enter any number to get its reverse: 65
Reverse = 56
C Program To Check Whether A String Is Palindrome Or Not.
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
{
char a[100], b[100];
printf(" Enter the string to check if it is a palindrome ");
gets(a);
strcpy(b , a);
strrev(b);
if (strcmp(a , b) == 0 )
printf(" Entered string is a palindrome.\n");
else
printf(" Entered string is not a pailndrome.\n");
getch();
return 0;
}
OUTPUT:
Enter the string to check if it is a palindrome: noon
Entered string is a palindrome
C Program To Check Whether A Given No. Is Palindrome Or Not.
#include <stdio.h>#include <conio.h>
#include <string.h>
{
int n, reversedInteger = 0, remainder, originalInteger;
printf("Enter an integer: ");
scanf("%d", &n);
originalInteger = n;
// reversed integer is stored in variable
while( n!=0 )
{
remainder = n%10;
reversedInteger = reversedInteger*10 + remainder;
n /= 10;
}
// palindrome if orignalInteger and reversedInteger are equal
if (originalInteger == reversedInteger)
printf("%d is a palindrome.", originalInteger);
else
printf("%d is not a palindrome.", originalInteger);
return 0;
}
ALSO READ:
-- Program To Print First Ten(10) Natural Numbers.
-- Program To Print Fibonacci Series Upto 100.
-- Program To Check Whether A Number Is Prime Or Not.
-- Program To Compute The Reverse Of A Number.
-- Program To Print A Semicolon Without Using A Semicolon.
-- Program To Display Function Without Using The Main Function.
-- Program To Print Any Print Statement Without Using Semicolon.
-- Program To Display Its Own Source Code As Its Output.
-- Program To Swap Two Strings Using strcpy() Function.
-- Program to accept a string and print the reverse of the given string.
-- Program To Get IP Address.
-- Program To Accept An Integer & Reverse It.
-- Program To Convert Given Number Of Days To A Measure Of Time Given In Years, Weeks & Days.
-- Program To Illustrate The Concept Of Unions.
-- Program To Find The Size Of A Union.
... Back To C++ Programs Index
... Back To C++ FAQ's Index
... Back To C Programs Index
... Back To C FAQ's Index
... Back To HR Interview Index
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com