0% found this document useful (0 votes)
8 views2 pages

S.No: 17 Date: 2022-03-13: Functions

Uploaded by

dasarig338
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

S.No: 17 Date: 2022-03-13: Functions

Uploaded by

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

Exp.

Name: Write a C program to implement String manipulation operations using library


S.No: 17 Date: 2022-03-13
functions

Page No:
Aim:
Write a program to implement the string manipulation operations by using string library functions.

ID: 214G1A0580
At the time of execution, the program should print the message on the console as:

Enter two strings :

For example, if the user gives the input as:

Enter two strings : Ram Laxman

then the program should print the result as:

The length of Ram : 3


The copied string of Ram : Ram
Ram is greater than Laxman
The concatenated string : RamLaxman

Note: Do use the printf() function with a newline character ( \n ) at the end.
Source Code:

Program612.c

#include<stdio.h>
#include<string.h>
void main()
{
char str1[100],str2[100];
int len;
printf("Enter two strings : ");
scanf("%s%s", str1, str2);
len=strlen(str1);
printf("The length of %s : %d\n",str1,len);
printf("The copied string of %s : %s\n",str1,strcpy(str1,str1));

2021-2025-CSE-B
int i = strcmp(str1,str2);
if (i==0)
{
printf("Both strings are equal\n", str1,str2);

}
Srinivasa Ramanujan Institute of Technology

else if (i>0)
{
printf("%s is greater than %s\n",str1,str2);
}
else
{
printf("%s is less than %s\n",str1,str2);
}
printf("The concatenated string : %s", strcat(str1,str2));
printf("\n");
}
Execution Results - All test cases have succeeded!

Test Case - 1

Page No:
User Output
Enter two strings : Ram Laxman

ID: 214G1A0580
The length of Ram : 3
The copied string of Ram : Ram
Ram is greater than Laxman
The concatenated string : RamLaxman

Test Case - 2

User Output
Enter two strings : Teacher Student
The length of Teacher : 7
The copied string of Teacher : Teacher
Teacher is greater than Student
The concatenated string : TeacherStudent

Test Case - 3

User Output
Enter two strings : Languages Programming
The length of Languages : 9
The copied string of Languages : Languages
Languages is less than Programming
The concatenated string : LanguagesProgramming

Test Case - 4

User Output
Enter two strings : Ganga Ganga
The length of Ganga : 5

2021-2025-CSE-B
The copied string of Ganga : Ganga
Both strings are equal
The concatenated string : GangaGanga

Srinivasa Ramanujan Institute of Technology

You might also like