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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:22:24+00:00 2026-06-13T03:22:24+00:00

I found the following code in my textbook: #include<stdio.h> void disp( int *k) {

  • 0

I found the following code in my textbook:

#include<stdio.h>

void disp( int *k)
{
printf("%d",*k);
}

int main( )
{
 int i ;
 int marks[ ] = { 55, 65, 75, 56, 78, 78, 90 } ;
 for ( i = 0 ; i <= 6 ; i++ )
 disp ( &marks[i] ) ;
 return 0;
}

 }

The code works just fine, but I have doubts regarding the logic:

  1. I am sending the address of variables of the array. But in the disp function I am using a pointer variable as the argument and printing the value of the pointer. So the type of argument sent from the main function should mismatch with the argument of disp. So how does it work?

  2. I tried to do the same by changing the disp function as

    void disp( int (&k))
    {
    printf("%d",*k);
    }
    

    but I am getting an error. What should I do to make it work by taking an address as an argument, i.e. void disp(int &k)?

  • 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-13T03:22:26+00:00Added an answer on June 13, 2026 at 3:22 am

    When you do: –

    int *k = &marks[i];
    

    The above statement is broken into: –

    int *k;   -> Integer Pointer
    k = &marks[i]; --> `k` points to the address of marks[i]
    

    So, basically, k is the an integer pointer, that points to the address of the current element in your array.

    So, when you print *k, it is equivalent to: – *(&marks[i]), which dereferences the value and prints the element marks[i].

    So, in the below code, you can understand, how the whole process of pointer assignment and de-referencing takes place: –

    int *k;  // Declaring integer pointer.
    
    // Actually 'k' is equal to the `&marks[i]`. 
    // '*k' is just the indication of it being a pointer
    k = &marks[i];      
    
    // Dereference pointer
    *k = *(&marks[i]); -->  = marks[i]
    
    printf("%d",*k);  --> printf("%d",marks[i]);
    

    Also, since you cannot declare variable like: –

    int &k = &marks[i];
    

    You cannot have them as parameter in your function: –

    void disp(int &k);
    

    Because, eventually the address of array element passed is stored in this variable. So, it has to be int *k.

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

Sidebar

Related Questions

i have found following code on online for suffix tree #include <stdio.h> #define E
Using reflector I found the following code in the System.Web.UI.WebControls.Parameter class: internal void UpdateValue(HttpContext
I found the following code to check the byte order state. It works with
I usualy found the following code: <a href=# onclick=func();return false>click</a> but sometime my browser
I've found the following code online, int binary_search(int a[], int low, int high, int
I found the following code in a library: class Bar { public: bool foo(int
Found the following code in our code base: public static final int DEFAULT_LENGTH =
I found the following code somewhere, but I am not understanding the code properly.
I found the following code in my team's project: Public Shared Function isRemoteDisconnectMessage(ByRef m
Hi I found the following code from this page JQuery UI DatePicker using 2

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.