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 8033661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:46:01+00:00 2026-06-05T01:46:01+00:00

I have a two dimensional array with a variable number of rows and two

  • 0

I have a two dimensional array with a variable number of rows and two columns, I am supposed to find the row that has the biggest difference in its columns. To make it more clear: I am given the lowest and highest temperature for n days and I am supposed to find the day where the difference between the temperatures is the largest (and if two days have this same difference, then I am supposed to give only the first one). However, I have never used multidimensional arrays, so I am not sure whether I can do something like this: a[i][1]-a[i][0]? (a[i] is the index of the day, and a[1] is the highest temperature for the day, a[0] is the lowest)

This part of my code looks like this:

int difference (int n, float a[maxn][2]) {
    float difference=a[0][1]-a[0][0];
    int index=0;
    for (int i=0; i<n; i++) {
        if (a[i][1]-a[i][0]>difference) {
            index=i;
            a[i][1]-a[i][0]=difference; //HERE I get the error message: lvalue required as left operand of assignment
        }
    }
    return index+1; //to get the day with the largest difference

If I don’t do it as an assignment, but I make the value equal to difference with ==, then it says that “statement has no effect”, so I was thinking that maybe I am not allowed to do what I am trying to do.

  • 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-06-05T01:46:03+00:00Added an answer on June 5, 2026 at 1:46 am
    1. You’re shadowing your function’s name – you might want to one of those difference to be something else.
    2. = only works with the variable you’re trying to assign to on the left. Try:

      difference = a[i][1] - a[i][0];
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two dimensional array, which represents columns and rows of data. I
I have a two dimensional array that I need to rotate 90 degrees clockwise,
I have a variable called names which is a two dimensional array. I declared
I have a two dimensional array that I need to load data into. I
I have two-dimensional array of integers. First index indicates the number of channels. The
I have a header file for a game that declares a two-dimensional array for
I have a two-dimensional array. When I print/dump this I get the following My
I have a two dimensional array with the following output Array ( [0] =>
I have a two dimensional array public class TwoDimensions { public static void main(String[]
I have a two dimensional JSON array where each element contains several attributes. The

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.