WRITE A C PROGRAM TO CONCATINATE TWO STRINGS - C C++ Java Programs - Examples

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Sunday, October 30, 2011

WRITE A C PROGRAM TO CONCATINATE TWO STRINGS


WRITE A PROGRAM TO CONCATINATE TWO STRINGS

#include<stdio.h>
#include<conio.h>
void main()
{
char a[25],b[25],c[25];
int i.j;
clrscr();
printf(“Enter first string:”);
scanf(“%s”,a);
printf(“Enter second string:”);
scanf(“%s”,b);
for(i=0;a[i]!=’\0’;i++)
c[i]=a[i];
for(j=0; b[j]!=’\0’; j++)
c[i+j]=b[j];
c[i+j]=’\0’;
printf(“The concatenated string is:\n%s,c”);
 getch();
}


OUTPUT :

Enter first string:  Net
Enter second string: World

The concatenated string is:  NetWorld

No comments:

Post a Comment