Thursday, November 22, 2012

C PROGRAM FOR CONCATENATING TWO STRING


/*C PROGRAM FOR  CONCATENATING TWO STRING */

#include<stdio.h>
#include<conio.h>

void main()
{
    char s[30],s1[30],s2[30];
    int i,j;
    clrscr();
    printf("\n\t CONCATENATING TWO STRING");
    printf("\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~");
    printf("enter the first string");
    scanf("%s",s);
    printf("enter the second string");
    scanf("%s",s1);
    for(i=0;s[i]!='\0';i++)
    s2[i]=s[i];
    for(j=0;s1[j]!='\0';j++)
    s2[i++]=s1[j];
    s2[i]='\0';
    printf("the concatenated string is %s",s2);
    getch();
}

























OUTPUT:

        
       
 CONCATENATING TWO STRING

Enter the first string: RAJ.

 Enter the second string: KUMAR

The concatenated string is: RAJKUMAR

0 comments:

Post a Comment