Subscribe Us

Responsive Advertisement

Advertisement

problem 15(concatenate of string)

 

problem 15(concatenate of string)


//problem 15(concatenate of string)

#include<stdio.h>

int main()

{

    char s[100],s1[100],ans[300];

    printf("Enter first string : ");

    gets(s);

    printf("Enter second string : ");

    gets(s1);

   int i,j;

   i=0;

   j=0;

  while(s[i]!=0)//store first string to ans

  {

      ans[j]=s[i];

      i++;

      j++;

  }

  i=0;

  while(s[i]!=0)//store second string to ans

  {

      ans[j]=s1[i];

      i++;

      j++;

  }

  ans[j]='\0';//assing null character to ans string;

  printf("concatenate string : %s",ans);

    return 0;

}


Post a Comment

0 Comments