#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char st1[15],st2[30];
int l;
clrscr();
printf("enter 2 strings: ");
gets(st1);
gets(st2);
l=stricmp(st2,st1);
if(l==0)
printf("same strings");
else
printf("different strings");
getch();
}
OR
#include<stdio.h>
#include<conio.h>
void main()
{
char st1[100],st2[100];
int i=0;
clrscr();
printf("\n enter 1st string :");
gets(st1);
printf("\n enter 2nd string :");
gets(st2);
while(st1[i]==st2[i]&&st1[i]!='\0')
i++;
if(st1[i]>st2[i])
printf("\n string 1 is greatest");
else if(st1[i]<st2[i])
printf("\n string 2 is greatest ");
else
printf("\n both the strings are equal");
getch();
}
#include<conio.h>
#include<string.h>
void main()
{
char st1[15],st2[30];
int l;
clrscr();
printf("enter 2 strings: ");
gets(st1);
gets(st2);
l=stricmp(st2,st1);
if(l==0)
printf("same strings");
else
printf("different strings");
getch();
}
OR
#include<stdio.h>
#include<conio.h>
void main()
{
char st1[100],st2[100];
int i=0;
clrscr();
printf("\n enter 1st string :");
gets(st1);
printf("\n enter 2nd string :");
gets(st2);
while(st1[i]==st2[i]&&st1[i]!='\0')
i++;
if(st1[i]>st2[i])
printf("\n string 1 is greatest");
else if(st1[i]<st2[i])
printf("\n string 2 is greatest ");
else
printf("\n both the strings are equal");
getch();
}
No comments:
Post a Comment