Write a C program to declare an integer pointer, store the address of an integer variable in it and display the value using the pointer.
Write a C program to declare an integer pointer, store the address of an integer variable in it and display the value using the pointer.
The declaration int *ptr defines a pointer that can store
the address of an integer variable. The address of number
is assigned using the address-of operator &.
Value = 25
Write a C program to define a pointer to a floating-point variable and display its value.
A pointer must be declared with a compatible data type. Here,
float *ptr stores the address of the floating-point
variable price.
Price = 125.50
Write a C program to define a character pointer and display the character stored in a variable.
The declaration char *ptr creates a pointer suitable for
storing the address of a character variable.
Grade = A
Write a C program to initialize a pointer at the time of declaration and display the value of the variable.
A pointer can be initialized when it is declared. In this example,
ptr immediately stores the address of number.
Number = 100
Write a C program to define two integer pointers and display the values of two variables through them.
Multiple pointers can be declared independently. Each pointer stores the address of its corresponding variable.
First value = 10
Second value = 20
Write a C program to define a pointer and assign it the address of different variables one after another.
A pointer variable can be reassigned to another variable of the same compatible type. After reassignment, dereferencing the pointer accesses the new variable.
First value = 15
Second value = 30
Write a C program to define a pointer and initialize it with
NULL. Check whether the pointer is NULL before using it.
A NULL pointer does not point to a valid object for
dereferencing. Checking a pointer before using it can help avoid
invalid memory access.
Pointer is NULL.
Write a C program to define an integer pointer and display both the address stored in the pointer and the value at that address.
The pointer stores the memory address of number.
The dereference operator * accesses the value stored
at that address.
Address stored in pointer = 0x7ff...
Value at address = 75
The exact memory address depends on the system.
Write a C program to define pointers for integer, float and character variables and display their values.
Pointer declarations use a data type corresponding to the type of
object whose address they store. This example demonstrates
int *, float * and char *.
Integer = 50
Float = 75.25
Character = B
Write a C program to define an integer pointer and use it to update a variable after initialization.
Once the pointer has been initialized with the variable's address,
assigning a value to *ptr changes the original variable.
This demonstrates the practical purpose of defining and initializing
a pointer.
Original marks = 70
Updated marks = 85