C program to returns the string, C/C++ Programming

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;

   }

Posted Date: 10/19/2012 7:58:16 AM | Location : United States







Related Discussions:- C program to returns the string, Assignment Help, Ask Question on C program to returns the string, Get Answer, Expert's Help, C program to returns the string Discussions

Write discussion on C program to returns the string
Your posts are moderated
Related Questions
I need Asp .net Facebook app project completion Project Description: We are urgently seeking a few remaining items to be completed, and the project to be deployed to live.

Write a ‘C’ program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

How does placing some code lines between comment symbols help in debugging the code? - Placing comment symbols /* */ around a code separates some code that coder believes might

Program of function overloading: class vector{                 private :                 int v[3];                   public:                 /*friend istream &

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b


Demonstration using Moss Open Source Machine Translation Project Description: Moses is an open source Statistical Machine Translation System. I need someone to provide me a d


Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Modify the FACTOR program in this chapter so that it repeatedly asks for a number and calculates its factorial, until the user enters 0, at which point it terminates. You can enclo