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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:25:15+00:00 2026-06-14T23:25:15+00:00

Why this program only works when I initialize a and b. I want to

  • 0

Why this program only works when I initialize a and b.
I want to pass it without initializing a and b, for example:

numChange(10,15);

Is this possible ?

#include <iostream>
using namespace std;
void numChange(int *x,int *y)
{
     *x = 99;
     *y = 77;
}

int main()
{
    numChange(10,15);
    //int a=10;
    //int b=15;
    //numChange(&a,&b);
    cout<<a<<" , "<<b<<endl;

    return 0;
}
  • 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-14T23:25:18+00:00Added an answer on June 14, 2026 at 11:25 pm

    Because you have defined your function to receive pointers, but when you call that function you are trying to pass an int.

    The compiler is expecting memory addresses and you are trying to pass constants.

    It does not make sense, you are trying to do something like 10 = 99; 15 = 77;?

    numChange(10,15);
        //int a=10;
        //int b=15;
    

    It seems that you are hopping that a = 10 = 99 and b = 15 = 77;

    If this was possible, it means that I could never (after the call of numChange(10,15);) make a variable to actually have the value 10 because 10 is “pointing” to 99 (is not).

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

Sidebar

Related Questions

there is this check-in-out program here at my workplace, it only takes the data
this program is for class to display the database in Listview.i want to add
Ok the only problem with this program is at the end where I try
I am just learning OpenMPI. Tried a simple MPI_Scatter example: #include <mpi.h> using namespace
This program builds a dictionary out of a list based on what two index
This program returns: package main import ( flag fmt ) func main() { num_agents
This program runs just fine, but for some reason when I ask for an
This program I use has it's own variables to set when you run it,
This program stores pairs in a map, counting the number of times a word
This program reads emails (really just a .txt file structured like an email) and

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.