Sunday, January 8, 2023

C Programming. Concatenation of two strings.

 Concatenation of two strings.

Program to concatenate two strings.


#include<stdio.h>
int main()
{
    char str1[50], str2[50], str3[100];
    int i=0,j=0;
    printf("Enter a string : ");
    gets(str1);
    printf("Enter another string : ");
    gets(str2);
   
    while(str1[i]!='\0'){
        str3[i]=str1[i];
        i++;                                
    }
   
    while(str2[j]!='\0') {
        str3[i]=str2[j];
        i++;
        j++;
    }
    str3[i]='\0';
   
    printf("After concatenation the array is : %s",str3);
   
    return 0;
}

No comments:

Post a Comment

Selection Sort Using C programming.

Selection sort is a simple and efficient sorting algorithm that works by repeatedly selecting the smallest (or largest) element from the un...