Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday, 3 January 2018

Write a C program to concatenate two strings

#include<stdio.h>
#include<string.h>
int main(){
    char str1[100],str2[100],output[200];
    clrscr();
    printf("Enter first string:");
    gets(str1);
    printf("Enter second string:");
    gets(str2);
    int i=0,j=0;
    for(i=0;i<strlen(str1);i++){
        output[j++] = str1[i];                     
    }
    for(i=0;i<strlen(str2);i++){
        output[j++] = str2[i];                 
    }
    for(i=0;i<j;i++){
        printf("%c",output[i]);         
    }
    getch();
}

No comments:

Post a Comment