#include <iostream.h>
#include <conio.h>
#include<string.h>void main()
{
char str1[30], srt2[30], str3[30];
cout<<"\n Enter 3 strings /Words one-by-one(press enter each time) :";
gets(str1);
gets(str2);
gets(str3);
/* Find Longest String */
if(strcmp(str1, str2) > 0)
{
if(strcmp(str1,str3)>0)
cout <<"\n The Longest string is : " << str1;
else
cout <<"\n The Longest string is : " << str3;
}
else
{
if(strcmp(str2,str3)>0)
cout <<"\n The Longest string is : " << str2;
else
cout <<"\n The Longest string is : " << str3;
}
/* Find smallest String */
if(strcmp(str1, str2) < 0)
{
if(strcmp(str1,str3)<0)
cout <<"\n The Smallest string is : " << str1;
else
cout <<"\n The Smallest string is : " << str3;
}
else
{
if(strcmp(str2,str3)<0)
cout <<"\n The Smallest string is : " << str2;
else
cout <<"\n The Smallest string is : " << str3;
}
getch();
}
The program is showing an error as"cannot convert intto char constant *"
ReplyDeletewhich compiler are you using?
ReplyDeleteInclude the header files correctly..