Computer Programming C Laboratory: String C Programs

Write a C program to concatenate two strings

Sample programs on Strings - C Programming

Write a C program to concatenate two strings.

String concatenation is the process of combining two strings into one. Here the user must supply two strings from the input. The concatenated string can be obtained by adding each character from the first string into new string after finishing this then add second string each character into new string and finally place the null character '\0' at the end of the new strings. This process can be easily obtained by using the string function strcat().

#include <stdio.h>

#include <conio.h>

void main()

{

      char str1[10], str2[10], str3[40];

      int i,j;

      clrscr();

      printf("Enter the two string : ");

      scanf("%s %s", strl, str2);

      for(i=0;str1[i]!= '\0';i++)

      {

            str3[i]= strl[i];

      }

      for(j=0;str2[j]!= '\0';j++)

      {

            str3[i]= str2[j];

            i++;

      }

      str3[i]='\0';

      printf("Concatenated string is...... %s\n", str3);

      getch();

}

OUTPUT 1

Enter the two string : venkat muni

Concatenated string is...... venkatmuni

OUTPUT 2:

Enter the two string: VRB Publishers

Concatenated string is...... VRBPublishers

 

Computer Programming C Laboratory: String C Programs : Tag: C Programming : - Write a C program to concatenate two strings


Computer Programming C Laboratory: String C Programs



Under Subject


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation



Related Subjects


English Essentials I

EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


தமிழர் மரபு - Heritage of Tamils

UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Calculus

MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I

PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Chemistry I

CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Makerspace

ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming Python

CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Fundamentals of Electrical and Electronics Engineering

EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Mechanical Engineering

ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Civil Engineering

CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing

CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I Laboratory

PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Applied Chemistry I Laboratory

CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming Python Laboratory

CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electronics and Electrical Engineering

EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing - Laboratory

CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation