Pointer Representation and Pointer Example Programs
Pointer Definition
- The pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.
Accessing The Address:
- & - Locate the Variable Address
- &variable
- ponter_variable = &variable;
Pointer Representation
// Example program for Pointer Representation
#include<stdio.h>
#include<conio.h>
void main()
{
int i=10;
printf("\nValue Of i :%d",i);
printf("\nAddress Of i :%d",&i);
}
Declaring Pointer Variables
- * and variable name
- pointer variable points to a variable of type data_type
Pointer Syntax:
data_type *pt_name;
Pointer Syntax Example:
int *p;
float *x;
Initialization Of Pointer Variable:
pointer_vaibale = &variable;
Pointer Example program: 1
// Pointer Representation Example Program : 1
#include<stdio.h>
#include<conio.h>
void main()
{
// Declaring Variables
int i=10;
int *Ptr;
// Assigning Pointer
Ptr=&i;
/ Printing Values of Pointer
printf("\nValue Of i :%d",i);
printf("\nAddress Of i :%d",&i);
printf("\nValue Of Ptr :%d",Ptr);
printf("\nAddress Of Ptr :%d",&Ptr);
printf("\nPtr's Pointer Value:%d",*Ptr);
printf("\nPtr Equal to &i :%d",*(&i));
}
Pointer Example Program: 2
// Pointer Representation Example Program : 2
#include<stdio.h>
#include<conio.h>
void main()
{
// Declaring Variables and Pointer
int i=10;
int *Ptr;
Ptr=&i;
// Printing Values of Pointer
printf("\nValue Of i :%d",i);
printf("\nAddress Of i :%d",&i);
printf("\nValue Of Ptr :%d",Ptr);
printf("\nAddress Of Ptr :%d",&Ptr);
printf("\nPtr's Pointer Value:%d",*Ptr);
printf("\nPtr Equal to &i :%d",*(&i));
// Change Values of Using Pointer
printf("\n\nWe Can Change Value Of i,Without Using i");
*Ptr=100;
printf("\nValue Of i :%d",i);
printf("\nAddress Of i :%d",&i);
printf("\nPtr's Pointer Value:%d",*Ptr);
getch();
}
C Pointer Example Programs
- Simple Pointer Example Program
- Simple Program for Print address of Variable Using Pointer in C
- Pointer Simple Example Program with Reference operator (&) and Dereference operator (*)
- Simple Example Program for Swap Numbers Using Pointers In C
- Print size of different types Using Pointer in C
- Simple Program for Add Two Numbers Using Pointer in C
- Simple Program for Increment and Decrement Integer Using Pointer in C
- Simple Program for Increment and Decrement Floating Point Using Pointer in C
- Simple Program for Find a difference between two Numbers Using Pointer in C
- Simple Program for Change the value of constant integer Using Pointer in C
- Simple Program for Print String Using Pointer in C
- Simple Program for Count vowels String Using Pointer in C
- Simple Program for Length of String Using Pointer In C
- Pointer to Pointer or Double Pointer Example Program In C
- Simple Program for Pointer and Array Example in C
- Simple Program for Sum of Integer an array using pointers in C
- Simple Program for Read, Print, and Sum of Integer in an array using pointers in C
- Simple Example Program for Passing pointers to functions In C
- Simple Example Program for Area Of Circle Using Pointer In C
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )