#include<stdio.h>
#include<conio.h>
#include<string.h>
void largstr(char *p1,char *p2);
void main()
{
char str1[10];
char str2[10];
clrscr();
printf(" \n \n Enter first string: \t ");
fflush(stdin);
gets(str1);
printf(" \n \n Enter second string: \t ");
fflush(stdin);
gets(str2);
largstr(str1,str2);
}
void largstr(char *p1, char *p2)
{
int l1, l2, i;
l1 = strlen(p1);
l2 = strlen(p2);
printf(" \n \n The largest string is: \t ");
if(l1 > l2)
{
for(i = 0; i < l1; i++ )
{
printf(" %c ",p1[i]);
}
}
else
{
for(i = 0; i < l2; i++ )
{
printf("%c",p2[i]);
}
}
getch();
}
OUTPUT:
Enter first string: rahul
Enter Second String: ankush
The largest string is: ankush
ALSO READ:
Sample C Program To Swap Two Strings Using strcpy() Function.
Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.
Sample C Program To Display Array Of Strings.
Sample C Program To Convert String To An Integer Using atoi() Function.
Sample C Program To Find The Length Of A String.
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com