Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 747931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:15:43+00:00 2026-05-14T14:15:43+00:00

Given the char * variables name1 , name2 , and name3 , write a

  • 0

Given the char * variables name1 , name2 , and name3 , write a fragment of code that assigns the largest value to the variable max (assume all three have already been declared and have been assigned values).

I’ve tried and came up with this:

    if ((strcmp(name1,name2)>0)&&(strcmp(name1,name3)>0)){
max=name1;
}
else if ((strcmp(name2,name1)>0)&&(strcmp(name2,name3)>0)){
max=name2;
}
else if((strcmp(name3,name1)>0)&&(strcmp(name3,name2)>0)){
max=name3;
}
else if(strcmp(name3,name1)==0){
max=name1,name3;
}
else if (strcmp(name2,name1)==0){
max=name2,name1;
}
else if (strcmp(name2,name3)==0){
max=name2,name3;
}
else{
max=name1,name2,name3;
}

However, I get this error Your code is incorrect. You are not handling the situation
               where two or more strings are equal.

Solved…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:15:43+00:00Added an answer on May 14, 2026 at 2:15 pm

    strcmp returns 0 when your strings are equal

    I’ll leave it for you to figure out why you aren’t handling it.

    Edit:

    Bob and Alice are 10 years old.
    What is the max age?

    Hint: it’s not undefined…. it’s 10.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code: string source = Some Unicode String; foreach( char value in
Given that the Windows API function GetGlyphIndices() can translate a 2 byte UNICODE char
Given the next code example, I'm unable to free the parameter const char* expression
I have a function that takes 2 returned variables from another function to write
I have been trying to write some code that asks the user for several
I have a C program that prints every environmental variable, whose name is given
In a given shell, normally I'd set a variable or variables and then run
Possible Duplicate: Implicit cast from char** to const char** Given the following code: void
I have a char that is given from fgets , and I would like
Given a class such as: class Person { private: char *name; public: Person() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.