program is to take two arguments and returns the


Program is to take two arguments and returns the string:

Program is to take two arguments and returns the string which is larger the larger string has larger ascii value invoke function from main

int compare(char *st,char *st2);

 

void main()

 {

 clrscr();

 int x;

 char st[20],st2[20];

 int ans;

 cout<<" enter the first string ";

 gets(st);

 cout<<" enter the second string ";

 gets(st2);

 ans=compare(st,st2);

 if (ans==0)

   cout<<" the larger string is "<

 else

   cout<<" the larger string is "<

 }

 

 int compare(char *st,char *st2)

   {

   int i=0;

   while(st[i]!='\0' && st2[i] != '\0')

     {

      if (st[i]==st2[i])

                {

       i++;

                }

       else if (st[i]>st2[i])

                 return 1;

       else

                 return 0;

     }

   return 0;

   }

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: program is to take two arguments and returns the
Reference No:- TGS0174948

Expected delivery within 24 Hours