Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Friday, February 13, 2015

C Program to reverse a string

C++ Program to reverse a string

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

void main()
{
clrscr();
char a[20],a1[20];
int i,j;
cout<<"Enter any String:"<<"
";

gets(a);    cout<<"Reverse of the string is: ";

for(i=0;a[i]!=
Read more »

Wednesday, February 11, 2015

C program to check whether given string is palindrome or not


C program to check whether given string is palindrome or not

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int i,j,flag=1,len;
char str[50];
clrscr();
printf("Enter any string:");
gets(str);
len=strlen(str);

for(i=0,j=len-1;i<len/2;++i,--j)
if(str[i]!=str[j])
{
flag=0;
break;
}
if(flag)
printf("String is palindrome");
else
printf("String is not palindrome");
getch();
}
Read more »