posted by .

int main()
int a=1;
int *p;
how do the following statements differ
1) p=&a;

2) *p=&a;

3) p=a;

4) printf("%d",p);

5) printf("%d",*p);

and what does int **a mean

  • computer -

    1) p points to a
    2) the address of a is stored where p is pointing
    3) p points to memory address 1
    4) prints the address stored in p
    5) prints the integer pointed to by p

  • computer -

    Hello Ray :)

    (Sorry if i have a bad English)

    - int a = 1 : You declared an integer variable, (imagine that is a box that contain the value 1 : [1].

    -int *p : You declared a pointer of integer . When we declare a pointer we need to put * before the variable . But * have an other meaning, when we use the pointers :

    Imgine that p is an arrow that indicate integer boxes ->[int ?]. p will contain the address of the box, and *p allows us to see what's in the box .

    1] Imagine that we give to "p" the address of "a", than the pointer p "->" will move and stuck to the box "a" like this : ->[ 1] "

    2]we put into the box that was pointed by "p ->[?int]" the location of a . ( useless :) )

    3] p will point to another memory slot, and we give to him an other box [] (in these case it will change nothing :) : p will point the same box "a" )

    And like Steve said :

    4] prints the address stored in p
    5] prints the integer pointed to by p

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. C programming

    Enter two integers between 1 to 10 3 4 Both numbers are less than 5. The sum of two numbers is:-1081825676 The product of two numbers is:-1081825680 why are the sum and product so weird?
  2. C Programming

    I am trying to find the sum of two integers. I entered the following program into the Visual Studio and it is telling me that there are errors. Can someone tell me where they are please?
  3. programming

    Having trouble with this program running, can anybody help solve my problem: #include <stdio.h> #include <stdlib.h> #include <string.h> void draw_x(int width, int height); int main(int argc, char *argv[]){ int width, …
  4. computer

    Which of the following does not print the numbers from I to 10?
  5. c++ program

    how can a modfiy this source code to a menu. #include <stdio.h> #include <stdlib.h> #include <time.h> main() { char cYesNo = '\0'; int iResp1 = 0; int iResp2 = 0; int iResp3 = 0; int iElaspedTime = 0; int iCurrentTime …
  6. computer sciece

    #include <stdio.h> #include <stdlib.h> int main() { int num[100]={0}; int i,n=0; for(i=0; num[i] != EOF ; i++,n++) { scanf("%d",&num[i]); } printf("%d\n", i); while(i=0;i<n;i++) printf("%d ",num[i]); printf("\n"); system("pause"); …
  7. Computer

    on C++, I want to make an operation like " 2x + y - z ", I wrote something like that but I can' t get the result, where is my mistake?
  8. C Programming

    Write a C program that accepts sales made by 5 sales reps for the 4 months that they have been selling the company's products. The program should then find the total sales for 4 months, total sales for each sales rep, and total sales …
  9. programming

    I have a general question. i was given a task to write a c code which gets an integer number as an input and prints the number of digits the number has. I have written a function that does it, but the problem is whenever the integer …
  10. Java

    1. Which of the following expression evaluates to a value of 15?

More Similar Questions