String

C++ Program to Concatenate Two Strings

Here you will get C++ program to concatenate two string without using library function. Below program will read two strings from user and then concatenate them to form third string. #include<iostream> using namespace std; int main() { char str1[30],str2[30],str3[60]; int i,j; cout<<“Enter first string:”; gets(str1); cout<<“\nEnter second string:”; gets(str2); for(i=0;str1[i]!=’\0′;++i) str3[i]=str1[i]; for(j=0;str2[j]!=’\0′;++j) str3[i+j]=str2[j]; str3[i+j]=’\0′; cout<<“\nThe …

C++ Program to Concatenate Two Strings Read More »

C++ Program to Check String is Palindrome or not

Here you will get C++ program to check string is palindrome or not. A string is called palindrome if it is equal to its reverse. For example bob is string palindrome. #include<iostream> using namespace std; int main() { int i,j,len,flag=1; char a[20]; cout<<“Enter a string:”; cin>>a; for(len=0;a[len]!=’\0′;++len); for(i=0,j=len-1;i<len/2;++i,–j) { if(a[j]!=a[i]) flag=0; } if(flag==1) cout<<“\nThe string …

C++ Program to Check String is Palindrome or not Read More »