Program to accept two strings and biggest among them - 100 Most Important C# Programs

88. Program to accept two strings and biggest among them

Code:

#include<stdio.h>

#include<conio.h>

int getline(char line[],int lim);

main( )

{

char str1[80],str2[80];

int len1,len2;

clrscr( );

printf(“enter first string”);

len1=getline(str1,80);

printf(“enter second string”);

len2=getline(str1,80);

if(len1 >len2)

printf(“first string bigger than second string”);

else

if(len1<len2)

printf(“second string bigger than first string”);

else

printf(“both strings are equal”);

getch( );

}

int getline(char line[],int lim)

{

int i;

for(Ii0;i<lim && ((line[i]=getchar( ))!=’\n’);i++)

if(line[i]==’\n’)

line[i]=’\0’;

return i;

}