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
Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

Can I free() pointers allocated  along with new? Can I delete pointers allocated along with malloc()? A: No. It is completely legal, moral, and wholesome to employ malloc() a

A: The procedure of encoding the parameter types along with the function/method name into a unique name is called as name mangling. The inverse procedure is called demangling. F

Need FTP Upload and MySQL Project Description: We are in need of an executable application that will be execute as a scheduled task on Windows Server 2008 R2 and can perform

A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof over three hours. The maximum charge for a

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

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

program that convert take decimal digit and convert it to binart digit

how c program starts executing?