WAP TO COMPARE LENGTH OF TWO STRINGS

 

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
Void main()
{
     char str[50],str2[50];
     int len=0,len2=0;
     clrscr();
     cout<<”Enter the first string:”;
     gets(str);
     cout<<”Enter the second string:”;
     gets(str2);
     for(int i=0;str[i]!=’\0’;i++)
    {
          len=len+1;
    }
    cout<<”Length of first string is:”<<len;
    for(int i=0;str2[i]!=’\0’;i++)
    {
           len2=len2+1;
    }
    cout<<”Length of second string is:”<<len2;
    if(len==len2)
         cout<<”\n Both strings are equal”;
    else
         cout<<”\n Both strings are not equal”;
    getch();
 }


      

Comments

Popular Posts