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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:07:46+00:00 2026-06-04T22:07:46+00:00

My homework problem: An array of integers named parkingTickets has been declared and initialized

  • 0

My homework problem:

An array of integers named parkingTickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element contains the number of tickets given today.)

A variable named ndays has been declared and initialized to hold the size of the array. (Thus, if today were January 18, ndays would have the value 18; if today were February 3, ndays would have the value 34.)

In addition, a variable named mostTickets has been declared, along with a variable k .

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

For this, I have the following code:

for(k = 0; k < ndays; k++) {
    if (parkingTickets[k] > parkingTickets[ndays]) {
        mostTickets = parkingTickets[k];
    }
}

But my exercise submitter is saying it’s wrong. What’s wrong with my code? I tried parkingTickets[ndays - 1] as well, but that doesn’t work either.

  • 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-04T22:07:47+00:00Added an answer on June 4, 2026 at 10:07 pm

    Your comparison is wrong. You’re comparing the current element to the last element each time. What you need to do is compare the current element to mostTickets. i.e.

    if(parkingTickets[k] > mostTickets)
    

    Also, for good measure, I would recommend initializing mostTickets to being parkingTickets[0].

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

Sidebar

Related Questions

I have a homework question that says: Problem 1: Given the array [ 22
For homework we have been given the bathroom synchronization problem. I have been struggling
I've been thinking about this homework question for a bit now. Given an number
My homework has a problem for example there is a category array $cat=array('1','4','5','7'); now
This is a homework problem. Let A[] is an array of integers and integer
I have the following homework problem: Given an array of scores, return true if
XXX----Yep, its a Homework problem, but yea I'm stuck. Why doesn't this print out
First, I'll admit this is homework but it has been around six years since
For a homework problem I was asked the question of given a set of
I am having a problem with my array homework, I need to enter a

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.