• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

string operations such as Copy, Length, Reversing, Palindrome, Concatenation

September 9, 2011 by ProjectsGeek Leave a Comment

Write a program to perform various string operations such as Copy, Length, Reversing, Palindrome, Concatenation
#include
#include
#include
void main()
{
int  no,m,ch ,i,j,n,k,flag=0;
char str[20],str2[20],str3[20],str4[20];
char wish;
clrscr();
do
{
menu:
printf(“\n1.length of the string.”);
printf(“\n2.copying string another.”);
printf(“\n3.concatination of two string”);
printf(“\n4.reversing the string”);
printf(“\n5.checking palindrome or not.”);
printf(“\n6.checking sub-string in the string.” );
printf(“\nEnter the choice:”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
printf(“Enter the string: “);
flushall();
gets(str);
for(i=1;str[i]!=’\0′;i++); //to find the length of the string
printf(“the length of the string is:%d “,i);
break;
case 2:
printf(“Enter the string: “);
flushall();
gets(str);
for(i=0;str[i]!=’\0′;i++)//TO COPY A STRING IN OTHER
{
str2[i]=str[i];
}
str2[i]=’\0′;
printf(“\n the copied string is: “);
puts(str2);
break;
case 3:
printf(“Enter the string: “);
flushall();
gets(str);
printf(“\n Enter the second string”);
flushall();
gets(str2);
i=0;
while(str[i]!=’\0′)
i++;
for(j=0;str2[j]!=’\0′;j++,i++)//TO CONCATINATE TWO STRING
str[i]=str2[j];
str[i]=’\0′;
printf(“\nthe concatinated string is: “);
puts(str);
break;
case 4:
printf(“Enter the string: “);
flushall();
gets(str);
i=0;
while(str[i]!=’\0′)
i++;
i–;
for(j=0;str[j]!=’\0′,i>=0;j++,i–)//TO REVERSE STRING
str2[j]=str[i];
str2[j]=’\0′;
printf(“\n the reverse string is: “);
puts(str2);
break;
case 5:
printf(“Enter the string: “);
flushall();
gets(str);
i=0;
while(str[i]!=’\0′)
i++;
i–;
flag=1;
for(j=0;i>j;j++,i–)
{ 

if(str[i]!=str[j])
{
flag=0;
break;
}
}
if(flag==1)
printf(“\nthe string is palindrom.”);
else
printf(“\nthe string is not palindrom.”);
break;
case 6:
printf(“Enter the string: “);
flushall();
gets(str);
printf(“\nEnter the second string: “);  //TO FIND WETHER SUBSTRING EXISTS OR NOT
gets(str4);
for(m=0;str[m]!=’\0′;m++);
for(k=0;k<=m-1;k++)
{
for(j=0;str4[j]!=’\0′;j++)
{
if(str[k+j]!=str4[j])
{
flag=0;
break;
}
}
if(str4[j]==’\0′)
{
flag=1;break;}
}
if(flag==1)
printf(“\nsubstring found at position:%d “,j+k);
else
printf(“\n substring donot exists”);
break;
default:
printf(“\n wrong choice!!!!”);
break;
}
printf(“\nwant to continue(y/n)”);
scanf(“%c”,&wish);
}
while(wish!=’n’);
getch();
}

Other Projects to Try:

  1. Set operations – Union, Intersection, Difference, Symmetric Difference using C
  2. String Operations with Pointers
  3. String Operations in C Program
  4. Factorial,Greatest Number,String Palindrome Shell code
  5. String Operations in C Language

Filed Under: Fundamentals of Datastructure Tagged With: Datastructure Assignments

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy