Wap To Find Length of String Without Using Strlen Function
Wap To Find Length of String Without Using Strlen Function
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char s1[18];
int i,c=0;
cout<<"Enter the string = ";
gets(s1);
for(i=0;s1[i]!='\0';i++)
{
c++;
}
cout<<"The length of string is = "<<c;
getch();
}
OUTPUT:
PROGRAM NO. 7
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
int j;
char s1[50],s2[50];
cout<<"Enter the 1st string = ";
gets(s1);
cout<<"Enter the 2nd string = ";
gets(s2);
j=strcmp(s1,s2);
if(j==0)
{
cout<<"both strings are equal";
}
else if(j>0)
{
cout<<"s1 is greater than s2";
}
else
{
cout<<"s2 is greater than s1";
}
getch(); }
OUTPUT:
PROGRAM NO. 8
WAP TO CONCATENATE TWO STRINGS.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char s1[50],s2[50];
cout<<"Enter the 1st string = ";
gets(s1);
cout<<"Enter the 2nd string = ";
gets(s2);
strcat(s1,s2);
cout<<"string after concatenation = ";
cout<<s1;
getch();
}
OUTPUT :