Results 1 to 7 of 7

Thread: We Want to Store the value a=10 by pointer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jul 2007
    Answers
    20

    We Want to Store the value a=10 by pointer

    We Want to Store the value a=10 by pointer in any one memory location. After some Time we can change the value of the a and also doe snot change the memory location. how?


  2. #2
    Contributing Member
    Join Date
    Apr 2007
    Answers
    58

    Re: We Want to Store the value a=10 by pointer

    Could you explain the question in detail giving sample variables?

    Regards,
    Anoop :)
    If its useful, dont forget to [COLOR="Red"]THANK[/COLOR] me :cool:

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Answers
    21

    Re: We Want to Store the value a=10 by pointer

    Quote Originally Posted by kaliswaranbsc View Post
    We Want to Store the value a=10 by pointer in any one memory location. After some Time we can change the value of the a and also doe snot change the memory location. how?
    hi friend
    let me to put answer;
    #include<stdio.h>
    #include<conio.h>
    void main(
    )
    {

    int a=100, *p;
    p=&a;
    printf("\n The address of a=%u and value of a=%d",&a,a);

    printf("\n P holding the address is =%u",p);
    a=a+10;
    printf("\n The address of a=%u and value of a=%u",&a,a);
    printf("\nP holding the number is =%u",p);

    getch();

    }

    try this u will get answer .

    Last edited by govindaraj123; 08-10-2007 at 08:28 AM. Reason: due to small syntax error

  4. #4
    Junior Member
    Join Date
    Jul 2007
    Answers
    21

    Re: We Want to Store the value a=10 by pointer

    Quote Originally Posted by kaliswaranbsc View Post
    We Want to Store the value a=10 by pointer in any one memory location. After some Time we can change the value of the a and also doe snot change the memory location. how?
    hi friend
    let me to put answer;
    #include<stdio.h>
    #include<conio.h>
    void main()
    {

    int a=100, *p;
    p=&a;
    printf("\n The address of a=%u and value of a=%d",&a,a);

    printf("\n P holding the address is =%u",p);
    a=a+10;
    printf("\n The address of a=%u and value of a=%d",&a,a);
    printf("\nP holding the number is =%u",p);

    getch();

    }

    try this u will get answer .


  5. #5
    Junior Member
    Join Date
    Jul 2007
    Answers
    20

    Re: We Want to Store the value a=10 by pointer

    Thankyou verymuch for answer my Dought sir,
    and i have another dought how to find the sizeof interger or float with out using sizeof() operator.


  6. #6
    Junior Member
    Join Date
    Jun 2007
    Answers
    3

    Re: We Want to Store the value a=10 by pointer

    Hi Friend Try this Piece of Code::

    int main()
    {
    printf("Size of int : %d bytes\n",sizeof(int));
    printf("Size of short int : %d bytes\n",sizeof(short int));
    printf("Size of long int : %d bytes\n\n", sizeof(long int));
    printf("Size of char is %d byte\n",sizeof(char));
    getch();
    return 0;
    }

    Regards,
    Shine


  7. #7
    Junior Member
    Join Date
    Jul 2007
    Answers
    1

    Re: We Want to Store the value a=10 by pointer

    hi friend
    i want some C & C++ questions for Aptitude please send
    thank u


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact