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
program that convert take decimal digit and convert it to binart digit

Project Description: Boots capture video from your YouTube channel and upload your own video to our channel or the copyright of the videos, bang, 3 parties, automatically delete

Question : (a) How does a structure differ from an array? (b) Describe how a structure differs from a union? (c) Declare a union called ‘clothes' which consists of the

What is conversion operator? Explain it with example.

draw the flow chart to print the fibonacci series upto n th terms

A string is said to be "Beautiful"€, if it contains only non repetitive alphabets

Write a main program that uses these system calls to echo the typed characters. The pseudo code will look something like: void traphandler ()  {    if (R0 == 0) { // read sys

I want source code for class booking system by using C++ Programming...Urgent

A: A dangling pointer arises while you use the address of an object after its lifetime is end. It may occur in situations such as returning addresses of automatic variables from a

A: 1.      By using const protects you against programming errors which inadvertently alter data. 2.      By using const allows function to procedure const and non-const actu