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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:51:35+00:00 2026-05-31T17:51:35+00:00

Possible Duplicate: when do we need to pass the size of array as a

  • 0

Possible Duplicate:
when do we need to pass the size of array as a parameter

So I just started working with arrays, I have 3 functions i need to create to get me to learn.

int sumarray(int a[], int n);

// a is an array of n elements
// sumarray must return the sum of the elements
// you may assume the result is in the range
//    [-2^-31, 2^31-1]

int maxarraypos(int a[], int n);

// a is an array of n elements
// maxarraypos must return the position of
//   the first occurrence of the maximum
//   value in a
// if there is no such value, must return 0

bool lexlt(int a[], int n, int b[], int m);

// lexicographic "less than" between an array
//   a of length n and an array b of length m
// returns true if a comes before b in
//   lexicographic order; false otherwise

How exactly would I create these functions?

For sumarray, I’m confused since an array stores something within a certain length. Why would need the second parameter n?

And also how would I test a function that consumes an array? I was thinking like sumarray([3], 3) .. is that right?

  • 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-31T17:51:36+00:00Added an answer on May 31, 2026 at 5:51 pm

    for sumarray, im confused since an array stores something within a certain length, why would need the second parameter n?

    You need the second parameter to tell you how long the array is. Arrays as parameters to methods in C don’t come with their length attached to them. So if you have a method that takes an array as a parameter, it can’t know the length unless you also pass that to the method. That’s what n is for.

    And also how would i test a function that consume’s an array, i was thinking like sumarray([3], 3) .. is that right ?

    No. You could say

    int myArray[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    

    and then

    int sum = sumarray(myArray, 10);
    

    To solve all of these, you’ll need loop (a for loop is best, I’m sure your lecturer provided examples on how to loop over the elements of an array). Beyond that, I’m not doing your homework. Ask specific, pointed questions, and I’d be happy to consider answering them though.

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

Sidebar

Related Questions

Possible Duplicate: Need to split arrays to sub arrays of specified size in Ruby
Possible Duplicate: Get all files from VSS for a given date? I need to
Possible Duplicate: Determine framework (CLR) version of assembly I need to get the CLR
Possible Duplicate: How to pass text in a textbox to javascript function? I need
Possible Duplicate: Need for prefixing a function with (void)… Hi, I am working with
Possible Duplicate: How to pass objects to functions in C++? My main program gives
Possible Duplicate: Do I need to release xib resources? IBOutlet WeaponStoreViewTableCell *tblCell; I have
Possible Duplicate: why do we need to pass in window and undefined into this
Possible Duplicate: I need help declaring a temarary array to hold a bitmap picture
Possible Duplicate: Multi value Dictionary I just need to store 2 value. How can

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.