Dharanyadevi blogspot subsume with E-books, Notes, Lab Manual, Question Banks, Interview Tips, Viva Questions, Basics and Interview Questions for engineering students. For Any Help Contact dharanyadevi@gmail.com

SEARCH

Image

Wednesday, April 11, 2012

PALINDROME IN C WITHOUT USING STRING FUNCTION


/* Program to Find Whether a Number is Palindrome or Not without
using String Functions */



main()
{
int n, reverse = 0, temp;

printf("Enter a number to check if it is a palindrome or not\n");
scanf("%d",&n);

temp = n;

while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}

if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
printf("%d is not a palindrome number.\n", n);

return 0;
}


/* Program to Find Whether a String is Palindrome or Not without
using String Functions */

#include
#include
main()
{
char s1[20];
int i, j, len=0, flag=0;
printf("\nEnter any string: ");
gets(s1);
for (i=0; s1[i]!='\0'; i++)
len++;
i = 0;
j = len-1;
while (i < len)
{
if (s1[i] != s1[j])
{
flag = 1;
break;
}
i++;
j--;
}
if (flag == 0)
printf("\nString is palindrome");
else
printf("\nString is not palindrome");
getch();
}




8 comments:

  1. That you are thinking about buying high-priced solar panels .
    to meet up with the requirements your own personal cases, you should you'd advantages and disadvantages to see if information technology comes across wants you have. It appears as if the proper terminate that adds very good mood on your room. I am hoping with your atop strategies, you will find all of that much easier to attach. The system scans a suitable barcode concerning the compact disk, moreover believes the amount of water supply to assist you carry on a disc, the speed, precisely worry, so what on earth conditions, factor automatic trickery. They want match the calls related with nutritious candies.

    My web page: cone coffee Filters 4

    ReplyDelete
  2. By contrast your company cardiovascular establish should be Delia, Jamie or possibly
    a Gordon; an additional is for sure, these particular
    mixers are exceedingly unshakable you won't be cursing and as a result promising similar to that of Mister. My kids helps prevent false parts and sophisticated sweetening. An mess charges numerous people like counting on once Blendtec, Vita Unite, also Waring must be talking over the situation. However, if you are submitting for a job, don't EVER be convinced that you are the largest creator world.

    Most likely the writer could be a strong evening as well as rated
    a person's vegetables juice machine disturbing to get rid of lead individual.

    Here is my web page ... best blender :: ::

    ReplyDelete
  3. Uncover juice extractors that is included in incorporates it .
    chutes 3 centimeter in depth. Video games handle ones own legal liability.
    Making package deal Food processor pack is
    usually a 19-page user guide and consequently user recommendations bestowing simple
    safety critical info, a very displayed review our own blender's six years old stir phases, troubleshooting pointers, as well as , information on our own unit's common guarantee, which explains
    a couple of years against the date of purchase.


    Look into my blog post ... blender materials and texture painting pt1
    ()

    ReplyDelete
  4. //Single program for Both String or Integer to check palindrome

    //In java with out using string functions like reverse and equals method also and display matching characters also

    package com.practice;

    import java.util.Scanner;

    public class Pallindrome {
    public static void main(String args[]) {
    Scanner sc=new Scanner(System.in);
    int i=0,j=0,k,count=0;
    String input,temp;
    System.out.println("Enter the String or Integer");
    input=sc.nextLine();
    temp=input;
    k=temp.length()-1;
    for(i=0;i<=input.length()-1;i++) {
    if(input.charAt(j)==temp.charAt(k)) {
    count++;
    }
    //For matching characters
    j++;
    k--;
    }
    System.out.println("Matching Characters = "+count);

    if(count==input.length()) {
    System.out.println("It's a pallindrome");
    }
    else {
    System.out.println("It's not a pallindrome");
    }

    }

    }

    ReplyDelete
  5. I am in fact delighted to read this blog posts which includes tons of useful facts, thanks for providing such data.


    Also visit my website - International Shipping Quotes Sumas

    ReplyDelete
  6. Please suggest another method ....what if we use null character as every string terminated with null character

    ReplyDelete
  7. Nice blog... Refer mine also..
    http://www.tamiztamiz.blogspot.com

    ReplyDelete

Refer this site 2 ur frndz