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

  • Home
  • SEARCH
  • 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 7615627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:41:20+00:00 2026-05-31T02:41:20+00:00

Sorry if the title is still ambiguous. I’m doing this assignment for school and

  • 0

Sorry if the title is still ambiguous.

I’m doing this assignment for school and below are my defined function prototypes, the main function and the change_array function.

The overall objective of this program is to allow users to input 5 different numbers and be stored into an array. Then what the change_array function does is to double (multiply by 2) any numbers that are below 10, however, it is currently not doing what it is intended to do. I’m really stuck, so I was wondering if anyone can point out my mistakes. I’m not asking for an exact answer, I just need some pointers and guidance.

What is going wrong is that the change_array function is not changing any of the values given by the users. So for example, if the user inputs, “3, 5, 6, 12, 32”, the output of my program is still “3, 5, 6, 12, 32”. But what I really want is, “6, 10, 12, 12, 32” after the arrays are passed back from the change_array function.

EDITED with complete program:

#include <stdio.h>
#define SIZE 5
void fill_array(double x[], int s);
void change_array(double x[], int s);
void print_array(double x[], int s);

main()
{
    double x[SIZE];

    fill_array(x, SIZE);
    printf("The array is as: \n");
    print_array(x, SIZE);
    change_array(x, SIZE);
    printf("After change, the array is: \n");
    print_array(x, SIZE);
}

void fill_array(double x[], int s)
{
    int i=0;

    printf("Please input 5 Non-Negative double numbers\n");
    for (i=0; i<s; i++) {
        printf("Number %d: ", i+1);
        scanf("%d", &x[i]);
        printf("\n");
    }
}

void change_array(double x[], int s)
{
    int i=0;

    for (i=0; i<s; i++) {
        if (x[i] < 10) {
              (x[i] = (x[i] * 2));
        }
    }
}

void print_array(double x[], int s)
{
    int i=0;

    for (i=0; i<s; i++) {
        printf("%ld \t", x[i]);
    }
    printf("\n");
}

My code is written in C.

  • 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-31T02:41:22+00:00Added an answer on May 31, 2026 at 2:41 am

    There is nothing wrong with change_array. It does indeed modify the values in the caller’s array.

    The problem lies the printing function, print_array. You are using the wrong format string for your printf. You need to use %f rather than %ld since these are floating point values and not integers.

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

Sidebar

Related Questions

Sorry for the long and yet still somehow vague title! A friend of mine
Sorry the title is not very clear. This is a follow up to my
Sorry for the semi-generic title, but I'm still pretty new at rails and couldn't
Sorry for the somewhat confusing title. Not sure really how to title this. My
Sorry about the title, I'm not exactly sure how to explain this with a
Sorry if the title's unclear, couldn't think of anything better since I'm still new
Sorry if the title is a little confusing. What I'm doing is creating a
I’m sorry if the title isn’t clear, but this is a weird problem. I
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry the title's so convoluted... I must've tried for ten minutes to get 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.