#include <stdio.h>
int main()
{
int var = 5;
printf("Value: %d\n", var);
printf("Address: %u\n", &var); //Notice, the ampersand(&) before var.
return 0;
}
Value: 5
Address: 37814048
Press any key to continue . . .
Before you get into the concept of pointers, let's first get familiar with address in C.
If you have a variable var in your program, &var will give you its address in the memory, where & is commonly called the reference operator.
You must have seen this notation while using scanf() function. It was used in the function to store the user inputted value in the address of var.
scanf("%d", &var); First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.