SlideShare a Scribd company logo
1 of 18
SARANYA K
AP/CSE
SRIT
 The string is actually a one-dimensional array of characters
which is terminated by a null character '0'.
 All the string handling functions are prototyped in: string.h
header file. So while using any string related function, don't
forget to include string.h.
 String constants have double quote marks around them.
 String constants can be assigned to a char array either with
no size specified, or the size can also be specified, but don't
forget to leave a space for the null character.
 Strings are often needed to be manipulated by the programmer
according to the need of a problem. Hence, C provides a
variety of string handling functions.
 String handling functions refers to a group of functions
implementing various operations on strings.
 Some of the operations performed by the string handling
functions includes:
› Length (number of characters in the string).
› Concatenation (adding two are more strings)
› Comparing two strings.
› Substring (Extract substring from a given string)
› Copy(copies one string over another)
 The various string handling functions supported by C are as
follows:
 strlen()
It is used to find the length of the string.
syntax:
strlen(string)
 strcpy()
It is used to copy one string to another.
syntax:
strcpy(string1,string2)
 strcat()
It is used to combine two strings.
syntax:
strcat(string1,string2)
 strcmp()
It is used to compare two strings.
syntax:
strcmp(string1,string2)
 Returns 0 if two strings are equal.
 Return value <0 if s1 is less than s2.
 Return value >0 if s1 is greater than s2.
 strrev()
It used to reverse a string.
syntax:
strrev(string)
 strlwr(), strupr()
It used to change the case of a string.
syntax:
strlwr(string)
strupr(string)
 strncpy()
It used to copy ‘n’ characters of one string to another.
 strstr()
It is used to determine the first occurrence of a
given string in another string.
 strncat()
It appends source string to destination string up to
specified length.
 strspn()
It is used to find up to what length two strings are
identical.
 strncmp()
It is used to compare ‘n’ character of two strings.
 strcmpi()
It is used to compare two strings without regarding the case.
 strnicmp()
It is used to compare first ‘n’ characters of two strings
without regarding the case.
 strchr()
It is used to determine the first occurrence of a given
character in a string.
 strrchr()
It is used to determine the last occurrence of a given
character in a string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[]="college";
int b;
clrscr();
b=strlen(a);
printf("nThe length of the string is %d",b);
getch();
}
Output:
The length of the string is 7
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="IT";
char b[ ]="Dept";
clrscr();
strcpy(a,b);
printf("nThe string is %s",a);
getch();
}
Output:
The string is Dept
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="IT";
char b[ ]="Dept";
clrscr();
strcat(a,b);
printf("nThe string is %s",a);
getch();
}
Output:
The string is ITDept
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="itdept";
char b[ ]="it";
int i;
clrscr();
i=strcmp(a,b);
if(i==0)
printf("nstrings are equal:%d",i);
else if(i<0)
printf("nstring1 is less than string2:%d",i);
else
printf("nstring1 is greater than string2:%d",i);
getch();
}
Output:
string1 is greater than string2:100
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="itdept";
clrscr();
printf("nThe string is :%s",a);
strupr(a);
printf("nThe string after conversion to uppercase :%s",a);
strlwr(a);
printf("nThe string after conversion to lowercase :%s",a);
getch();
}
The string is : itdept
The string after conversion to uppercase :ITDEPT
The string after conversion to lowercase : itdept
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="Dept";
clrscr();
printf("nThe string is %s",strrev(a));
getch();
}
Output:
The string is tpeD
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[ ]="itdept";
char b[15];
int i=0;
clrscr();
strncpy(b,a,2);
b[2]='0';
printf("nThe string is :%s",b);
getch();
}
Output:
The string is :it
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int len,i,j;
char str[15];
clrscr();
printf("n Enter the string:");
scanf("%s",str);
len=strlen(str);
for(i=0,j=len-1;i<len/2;i++,j--)
{
if(str[i]!=str[j])
{
printf("n The String is not a palindrome");
getch();
exit(0);
}
}
printf("n The String is a palindrome");
getch();
}
Output:
Enter the string: abcba
The String is a palindrome

More Related Content

What's hot

What's hot (20)

Unit 8. Pointers
Unit 8. PointersUnit 8. Pointers
Unit 8. Pointers
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Arrays
ArraysArrays
Arrays
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
Lecture 17 - Strings
Lecture 17 - StringsLecture 17 - Strings
Lecture 17 - Strings
 
Lecture 18 - Pointers
Lecture 18 - PointersLecture 18 - Pointers
Lecture 18 - Pointers
 
String & its application
String & its applicationString & its application
String & its application
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
Lecture 8- Data Input and Output
Lecture 8- Data Input and OutputLecture 8- Data Input and Output
Lecture 8- Data Input and Output
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
14 strings
14 strings14 strings
14 strings
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C ProgrammingLecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
C++ theory
C++ theoryC++ theory
C++ theory
 

Similar to Strings (20)

Strings in c
Strings in cStrings in c
Strings in c
 
String handling
String handlingString handling
String handling
 
string in C
string in Cstring in C
string in C
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
 
String notes
String notesString notes
String notes
 
String functions in C
String functions in CString functions in C
String functions in C
 
Strings part2
Strings part2Strings part2
Strings part2
 
C string
C stringC string
C string
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Computer Programming Utilities the subject of BE first year students, and thi...
Computer Programming Utilities the subject of BE first year students, and thi...Computer Programming Utilities the subject of BE first year students, and thi...
Computer Programming Utilities the subject of BE first year students, and thi...
 
Strings
StringsStrings
Strings
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
Unitii string
Unitii stringUnitii string
Unitii string
 
Team 1
Team 1Team 1
Team 1
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
C q 3
C q 3C q 3
C q 3
 
Week6_P_String.pptx
Week6_P_String.pptxWeek6_P_String.pptx
Week6_P_String.pptx
 
Chapter 4 (Part II) - Array and Strings.pdf
Chapter 4 (Part II) - Array and Strings.pdfChapter 4 (Part II) - Array and Strings.pdf
Chapter 4 (Part II) - Array and Strings.pdf
 
Operation on string presentation
Operation on string presentationOperation on string presentation
Operation on string presentation
 

Recently uploaded

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

Strings

  • 2.  The string is actually a one-dimensional array of characters which is terminated by a null character '0'.  All the string handling functions are prototyped in: string.h header file. So while using any string related function, don't forget to include string.h.  String constants have double quote marks around them.  String constants can be assigned to a char array either with no size specified, or the size can also be specified, but don't forget to leave a space for the null character.
  • 3.  Strings are often needed to be manipulated by the programmer according to the need of a problem. Hence, C provides a variety of string handling functions.  String handling functions refers to a group of functions implementing various operations on strings.  Some of the operations performed by the string handling functions includes: › Length (number of characters in the string). › Concatenation (adding two are more strings) › Comparing two strings. › Substring (Extract substring from a given string) › Copy(copies one string over another)
  • 4.  The various string handling functions supported by C are as follows:  strlen() It is used to find the length of the string. syntax: strlen(string)  strcpy() It is used to copy one string to another. syntax: strcpy(string1,string2)  strcat() It is used to combine two strings. syntax: strcat(string1,string2)
  • 5.  strcmp() It is used to compare two strings. syntax: strcmp(string1,string2)  Returns 0 if two strings are equal.  Return value <0 if s1 is less than s2.  Return value >0 if s1 is greater than s2.  strrev() It used to reverse a string. syntax: strrev(string)  strlwr(), strupr() It used to change the case of a string. syntax: strlwr(string) strupr(string)
  • 6.  strncpy() It used to copy ‘n’ characters of one string to another.  strstr() It is used to determine the first occurrence of a given string in another string.  strncat() It appends source string to destination string up to specified length.  strspn() It is used to find up to what length two strings are identical.
  • 7.  strncmp() It is used to compare ‘n’ character of two strings.  strcmpi() It is used to compare two strings without regarding the case.  strnicmp() It is used to compare first ‘n’ characters of two strings without regarding the case.  strchr() It is used to determine the first occurrence of a given character in a string.  strrchr() It is used to determine the last occurrence of a given character in a string.
  • 8. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[]="college"; int b; clrscr(); b=strlen(a); printf("nThe length of the string is %d",b); getch(); } Output: The length of the string is 7
  • 9. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="IT"; char b[ ]="Dept"; clrscr(); strcpy(a,b); printf("nThe string is %s",a); getch(); } Output: The string is Dept
  • 10. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="IT"; char b[ ]="Dept"; clrscr(); strcat(a,b); printf("nThe string is %s",a); getch(); } Output: The string is ITDept
  • 11. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="itdept"; char b[ ]="it"; int i; clrscr(); i=strcmp(a,b); if(i==0) printf("nstrings are equal:%d",i); else if(i<0) printf("nstring1 is less than string2:%d",i);
  • 12. else printf("nstring1 is greater than string2:%d",i); getch(); } Output: string1 is greater than string2:100
  • 13. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="itdept"; clrscr(); printf("nThe string is :%s",a); strupr(a); printf("nThe string after conversion to uppercase :%s",a); strlwr(a); printf("nThe string after conversion to lowercase :%s",a); getch(); }
  • 14. The string is : itdept The string after conversion to uppercase :ITDEPT The string after conversion to lowercase : itdept
  • 15. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="Dept"; clrscr(); printf("nThe string is %s",strrev(a)); getch(); } Output: The string is tpeD
  • 16. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[ ]="itdept"; char b[15]; int i=0; clrscr(); strncpy(b,a,2); b[2]='0'; printf("nThe string is :%s",b); getch(); } Output: The string is :it
  • 17. #include<stdio.h> #include<conio.h> #include<string.h> void main() { int len,i,j; char str[15]; clrscr(); printf("n Enter the string:"); scanf("%s",str); len=strlen(str);
  • 18. for(i=0,j=len-1;i<len/2;i++,j--) { if(str[i]!=str[j]) { printf("n The String is not a palindrome"); getch(); exit(0); } } printf("n The String is a palindrome"); getch(); } Output: Enter the string: abcba The String is a palindrome