It is program that will take entry of tho sentences as per user's entry using different function the two sentences are first merged then they are displayed with an another fuction.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void findlength()
{
char str[30];
int l=0;
cout<<"\n Enter the string (n<=30) ";
gets(str);
while(str[l]!='\0')
{
l++;
}
cout<<"\n Length Of the given String is: "<<l<<endl;
}
void compare()
{
char str1[30], str2[30];
int i=0,j=0,i=0,flag=0;
cout<<"\n Enter the string1 (n<=30) ";
gets(str1);
while(str1[i]!='\0')
{
i++;
}
cout<<"\n Enter the string2 (n<=30) ";
gets(str2);
while(str2[j]!='\0')
{
j++;
}
if(j!=i)
{
cout<<"\n Strings are not Equal ";
}
else
{
for(i=0;i<i;i++)
{
if(str1[i]!=str2[i])
{
flag=1;
break;
}
}
if(flag==1)
{
cout<<"\n Strings are not Equal ";
}
else
{
cout<<"\n Strings are Equal ";
}
}
}
void concat()
{
char str1[30], str2[30];
int i=0,j=0,i=0,flag=0;
cout<<"\n Enter the string1 (n<=30) ";
gets(str1);
while(str1[i]!='\0')
{
i++;
}
cout<<"\n Enter the string2 (n<=30) ";
gets(str2);
while(str2[j]!='\0')
{
j++;
}
for(i=0;i<j;i++)
{
str1[i+i]=str2[i];
}
str1[i+j]='\0';
cout<<"\n The concatenated String is: ";
puts(str1);
}
void main()
{
clrscr();
cout<<"Enter your choice \n \t1.Find length of string\n\t"
"2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
char ch;
cin>>ch;
do
{
if(ch=='1')
findlength();
if(ch=='2')
compare();
if(ch=='3')
concat();
cout<<"Enter your choice \n \t1.Find length of string\n\t"
"2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
cin>>ch;
}while(ch!='4');
getch();
}
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void findlength()
{
char str[30];
int l=0;
cout<<"\n Enter the string (n<=30) ";
gets(str);
while(str[l]!='\0')
{
l++;
}
cout<<"\n Length Of the given String is: "<<l<<endl;
}
void compare()
{
char str1[30], str2[30];
int i=0,j=0,i=0,flag=0;
cout<<"\n Enter the string1 (n<=30) ";
gets(str1);
while(str1[i]!='\0')
{
i++;
}
cout<<"\n Enter the string2 (n<=30) ";
gets(str2);
while(str2[j]!='\0')
{
j++;
}
if(j!=i)
{
cout<<"\n Strings are not Equal ";
}
else
{
for(i=0;i<i;i++)
{
if(str1[i]!=str2[i])
{
flag=1;
break;
}
}
if(flag==1)
{
cout<<"\n Strings are not Equal ";
}
else
{
cout<<"\n Strings are Equal ";
}
}
}
void concat()
{
char str1[30], str2[30];
int i=0,j=0,i=0,flag=0;
cout<<"\n Enter the string1 (n<=30) ";
gets(str1);
while(str1[i]!='\0')
{
i++;
}
cout<<"\n Enter the string2 (n<=30) ";
gets(str2);
while(str2[j]!='\0')
{
j++;
}
for(i=0;i<j;i++)
{
str1[i+i]=str2[i];
}
str1[i+j]='\0';
cout<<"\n The concatenated String is: ";
puts(str1);
}
void main()
{
clrscr();
cout<<"Enter your choice \n \t1.Find length of string\n\t"
"2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
char ch;
cin>>ch;
do
{
if(ch=='1')
findlength();
if(ch=='2')
compare();
if(ch=='3')
concat();
cout<<"Enter your choice \n \t1.Find length of string\n\t"
"2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
cin>>ch;
}while(ch!='4');
getch();
}
EmoticonEmoticon