c++ programs examples

C++ Program to join two strings in a 3rd string without using any string function

c++ programs examples
/* 18. Write a program to join two string in a third string without
       using any string function */

 #include<iostream.h>
 #include<conio.h>
 void main()
 {
  clrscr();
  char s1[10],s2[10],s3[21];
  int i,j;
  cout<<"Enter first string value"<<endl;
  cin>>s1;
  cout<<"Ente second string value"<<endl;
  cin>>s2;
  for(i=0;s1[i]!='\0';i++)
   s3[i]=s1[i];
  for(j=0;s2[j]!='\0';j++)
  {
   s3[i++]=s2[j];
   }
   s3[i]='\0';
   cout<<"s3="<<s3;
   getch();
  }

Leave a Reply

Your email address will not be published. Required fields are marked *