Google Ads

Wednesday, May 27, 2009

Concatenation of String

CONCATENATION OF GIVEN STRINGS

#include”stdio.h”

#include “conio.h”

#include

void main()

{

char str1[10],str2[20],d[20]=" ",ch;

int i=0,j=0;

clrscr();

printf("\nEnter the First String : ");

scanf("%s",str1);

printf("\nEnter the Second String : ");

scanf("%s",str2);

ch=str1[i];

while(ch!='\0')

{

d[j]=str1[i];

i++;

j++;

ch=str1[i];

}

i=0;

ch=str2[i];

while(ch!='\0')

{

d[j]=str2[i];

i++;

j++;

ch=str2[i];

}

printf("\nThe Concatenated String : %s",d);

getch();

}


Output will be

Enter the First String : hello

Enter the Second String : world

The Concatenated String : helloworld


No comments:

Post a Comment