8 Mar 2013

Palindrome_String



/*

program to check whether a string is palindrome or not in c++

*/

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,k,flag=0;
char a[80];
cout<<"Enter the string:";
gets(a);
k=strlen(a);
for(i=0,j=k-1;i<=j;i++,j--)
{
if(a[i]!=a[j])
{
flag=1;
break;
}
}
if(flag>0)
cout<<"String is not palindrome.";
else
cout<<"String is palindrome.";
getch();
}

Categories: ,

Related Posts:

  • Command Line arguments //Command Line Arguments   #include <stdio.h> int main ( int argc, char *argv[] ) { if ( argc != 2 ) /* argc should be 2 for correct execution */ { /* We print argv[0] assuming it is the program … Read More
  • Binary to Decimal Conversion /* program to convert binary no. to decimal no.....   */ #include<iostream.h>#include<conio.h>#include<math.h>void main(){unsigned long int a,b,c=0,s=0,n;clrscr();cout<<"Enter your binary numb… Read More
  • Insertion and Quick Sort /*  A program to sort a range of numbers with Insertion and Quicksort, check their sorting time and prompt the result on the screen */#include <stdio.h>#include <iostream.h>#include <stdlib.h>#inclu… Read More
  • Concatenate two Strings /* Program to concatenate 2 strings...    */ #include<iostream.h>#include<conio.h>#include<stdio.h>void main(){clrscr();char a[200],b[200];int c,d;cout<<"Enter the first string:";cin.getl… Read More
  • Words Count in String /* Program to count the no. of words in a string.... */ #include<iostream.h>#include<conio.h>#include<stdio.h>void main(){clrscr();char a[50];int i,j,c=1;cout<<"Enter the string:";gets(a);for(i=0;… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger