Program in C to concatenate two strings

#include
#include
#include
void main()
{
            char str1[20],str2[20],str3[50],ch;
            int len1,len2,i,j;
            clrscr();
            printf(“n Enter the String 1:-“);
            scanf(“%s”,&str1);
            printf(“n Enter the String 2:-“);
            scanf(“%s”,&str2);
            for(len1=0;str1[len1]!=’’;len1++);
            for(len2=0;str2[len2]!=’’;len2++);
            for(i=0;i<(len1+len2);i++)      
            {
            if(i            {
            str3[i]=str1[i];
            j=0;
            }
            else
            {
            str3[i]=str2[j];
            j++;
            }
            }
            str3[i]=’’;
            printf(“n%s + %s = %s”,str1,str2,str3);
getch();
}


Output




leave your comment


Your email address will not be published. Required fields are marked *

Advertisement

Related Events

Startup Expo – Keynote Speaker Sessions, Hindu College, University of Delhi, 9th October 2021
Startup Expo – Keynote Speaker Sessions, Hindu College, University of Delhi, 9th October 2021

Startup Expo –...

October 9, 2021 - October 9, 2021
Hindu College, University of Delhi
Punjab Half Marathon 2021 (10th Edition) 24 October 2021
Punjab Half Marathon 2021 (10th Edition) 24 October 2021

Punjab Half Marathon...

October 24, 2021 - October 24, 2021
Chandigarh Club Sector 1
Be Healthy Noida Half Marathon, Gautam Buddh Nagar, Uttar Pradesh on 27 March 2022
Be Healthy Noida Half Marathon, Gautam Buddh Nagar, Uttar Pradesh on 27 March 2022

Be Healthy Noida Hal...

March 27, 2022 - March 27, 2022
Noida-Greater Noida Expressway, Gautam Buddh Nagar, Uttar Pradesh
Air Heroes Half Marathon 2022 (2nd Edition), Delhi on 9 January 2022
Air Heroes Half Marathon 2022 (2nd Edition), Delhi on 9 January 2022

Air Heroes Half Mara...

January 9, 2022 - January 9, 2022
Sector 24 Dwarka | South West Delhi
English English हिन्दी हिन्दी