100% found this document useful (1 vote)
423 views3 pages

P 8

The document describes a C program to implement string operations like comparison, concatenation and calculating string length. It includes an algorithm with 9 steps to read strings, calculate length using strlen(), compare using strcmp(), concatenate using strcat() and print the results. The program defines functions to calculate string length, compare strings and concatenate them. It gets input from the user, calls the functions and prints the output.

Uploaded by

sufyan shaik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
423 views3 pages

P 8

The document describes a C program to implement string operations like comparison, concatenation and calculating string length. It includes an algorithm with 9 steps to read strings, calculate length using strlen(), compare using strcmp(), concatenate using strcat() and print the results. The program defines functions to calculate string length, compare strings and concatenate them. It gets input from the user, calls the functions and prints the output.

Uploaded by

sufyan shaik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SUB CODE: 21CPL17/27

Program 8

Write functions to implement string operations such as compare, concatenate, string


length. Convince the parameter passing techniques.

Algorithm:

Step1: start

Step 2: read two strings

Step 3: calculate the string length using strlen()

Step 4: compare the string using strcmp()

Step 5: concatenate the strings using strcat()

Step 6: print the stringlength

Step 7: print strings are equal or not equal

Step 8: print concatenated sting

Step 9: stop

GNDEC/CPL
SUB CODE: 21CPL17/27

FLOWCHART:

GNDEC/CPL
SUB CODE: 21CPL17/27

PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void stringlength(char a[100],char b[100]);
void concatenate(char a[100],char b[100]);
void stringcompare(char a[100],char b[100]);
void main()
{
char p[100],q[100],ch[100];
int len1,len2;
clrscr();
printf("Enter the first string:\n");
gets(p);
printf("Enter the second string:\n");
gets(q);
stringlength(p,q);
stringcompare(p,q);
concatenate(p,q);
getch();
}

void stringlength(char a[100], char b[100])


{
int len1,len2;
len1=strlen(a);
len2=strlen(b);
printf("First string length is :%d \nSecond string lenght is: %d",len1,len2);
}
void concatenate(char a[100], char b[100])
{
printf("The concatenated String is :%s ", strcat(a,b));
}

void stringcompare(char a[100], char b[100])


{
if(strcmp(a,b)==0)

printf("\nSTRINGS ARE EQUAL\n");

else

printf("\nSTRINGS ARE NOT EQUAL\n");

GNDEC/CPL

You might also like