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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:04:29+00:00 2026-06-15T18:04:29+00:00

I’m really puzzled as to how to call the function. UPDATED code in response

  • 0

I’m really puzzled as to how to call the function. UPDATED code in response to one or more answers. Current code and build errors are listed below.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//function prototypes
void signs(int x[], int size, int *negPtr, int *zeroPtr, int *posPtr);
double average(int x[], int size, int *greaterPtr);

int main()
{
//variable declarations
int zeroCounter, posCounter, negCounter, greaterThanAveCounter;
double ave;
int i;
int arr[63];
int size = 63;
int x[63], int size, int* negPtr, int* zeroPtr, int* posPtr, int* greaterPtr;

//seeding the random number generator function with the time
srand(time(NULL));

//filling the array with random numbers from the interval [-15, 40]
for(i=0; i<63; i++)
{
    arr[i] = rand()%(40-(-15)+1)+(-15);
}

//printing the array to the screen 9 elements per line
for(i=0; i<63; i++)
{
    if(i%9==0)
    {
        printf("\n");
    }
    printf("%5d",arr[i]);
}

//call function signs
signs (x, size, negPtr, zeroPtr, posPtr);

printf("\n\nThe number of elements that are negative is: %d\n",negCounter);
printf("The number of elements that are equal to zero is: %d\n",zeroCounter);
printf("The number of elements that are positive is: %d\n",posCounter);


//call function average
average(x, size, greaterPtr);

printf("The average of all the elements is: %.2f\n",ave);
printf("The number of elements that are greater than the average is: %d\n",greaterThanAveCounter);

return 0;
}



/***************************************************************************
signs:
This function finds the number of elements that are negative, positive and
equal to zero in an integer array. The number of elements that are negative,
positive and equal to zero are returned by 3 pointers that the function
receives.

Inputs
1. The integer array
2. The size of the aray
3. An integer pointer to the negative counter
4. An integer pointer to the zero counter
5. An integer pointer to the positive counter
***************************************************************************/
void signs(int x[], int size, int *negPtr, int *zeroPtr, int *posPtr)
{
int i;
for (i=0; i<size; i++)
{
    if(x[i]<0)
    {
        (*negPtr)++;
    }
    else if (x[i]==0)
    {
        (*zeroPtr)++;
    }
    else
    {
        (*posPtr)++;
    }
}
}



/***************************************************************************
average:
This function finds the average and the number of elements that are greater
than the average in an integer array. The function returns the value of the
average and returns the number of elements that are greater than the average
using a pointer that the function should receive.

Inputs
1. The integer array
2. The size of the aray
3. An integer pointer to the greater than average counter
***************************************************************************/
double average(int x[], int size, int *greaterPtr)
{
int i;
double ave;
int sum=0;

for (i=0; i<size; i++)
{
    sum+=x[i];
}

ave = (double)sum/size;

*greaterPtr = 0;
for (i=0; i<size; i++)
{
    if(x[i]>ave)
    {
        (*greaterPtr)++;
    }
}
return ave;
}

New Errors

  • (32): error C2059: syntax error : ‘type’
  • (35): warning C4244: ‘function’ : conversion from ‘time_t’ to
    ‘unsigned int’, possible loss of data
  • (54): error C2065: ‘negPtr’ : undeclared identifier

  • (54): warning C4047: ‘function’ : ‘int *’ differs in levels of
    indirection from ‘int’

  • (54): warning C4024: ‘signs’ : different types for formal and
    actual parameter 3
  • (54): error C2065: ‘zeroPtr’ : undeclared identifier
  • (54): warning C4047: ‘function’ : ‘int *’ differs in levels of
    indirection from ‘int’

  • (54): warning C4024: ‘signs’ : different types for formal and
    actual parameter 4

  • (54): error C2065: ‘posPtr’ : undeclared identifier
  • (54): warning C4047: ‘function’ : ‘int *’ differs in levels of
    indirection from ‘int’

  • (54): warning C4024: ‘signs’ : different types for formal and actual
    parameter 5

  • (62): error C2065: ‘greaterPtr’ : undeclared identifier

  • (62): warning C4047: ‘function’ : ‘int *’ differs in levels of
    indirection from ‘int’

  • (62): warning C4024: ‘average’ : different types for formal and
    actual parameter 3
  • 1> 1>Build FAILED.
  • 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-15T18:04:30+00:00Added an answer on June 15, 2026 at 6:04 pm
    double average(int x[], int size, int *greaterPtr);
    

    is how you declare a function. To call it, you need something like:

    int a[10], b, *c;             // should also set these to sensible values.
    double d = average (a, b, c);
    

    In terms of your newly added error messages, I’ll help out with a few:

    int x[63], int size, int* negPtr, int* zeroPtr, int* posPtr, int* greaterPtr;
    

    This is not how you define multiple variables, it should be:

    int x[63], size, *negPtr, *zeroPtr, *posPtr, *greaterPtr;
    

    That’s probably the single cause of most of your current problems (I haven’t confirmed this, it’s more from a quick analysis).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.