poiner in c

#include <stdio.h>
int main() {
   int c = 5;
   int *p = &c;

   printf("%d", *p);  // 5
   return 0; 
}

4.5
4
Tcbrazil 100 points

                                    int c, *pc;

// pc is address but c is not
pc = c; // Error

// &amp;c is address but *pc is not
*pc = &amp;c; // Error

// both &amp;c and pc are addresses
pc = &amp;c;

// both c and *pc values 
*pc = c;

4.5 (4 Votes)
0
0
5
Timidger 100 points

                                    #include &lt;stdio.h&gt;
int main()
{
    int var =10;
    int *p;
    p= &amp;var;

    printf ( &quot;Address of var is: %p&quot;, &amp;var);
    printf ( &quot;\nAddress of var is: %p&quot;, p);

    printf ( &quot;\nValue of var is: %d&quot;, var);
    printf ( &quot;\nValue of var is: %d&quot;, *p);
    printf ( &quot;\nValue of var is: %d&quot;, *( &amp;var));

    /* Note I have used %p for p's value as it represents an address*/
    printf( &quot;\nValue of pointer p is: %p&quot;, p);
    printf ( &quot;\nAddress of pointer p is: %p&quot;, &amp;p);

    return 0;
}

0
0
4.67
3
Eugene_sunic 105 points

                                    int* pc, c, d;
c = 5;
d = -15;

pc = &amp;c; printf(&quot;%d&quot;, *pc); // Output: 5
pc = &amp;d; printf(&quot;%d&quot;, *pc); // Ouptut: -15

4.67 (3 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source