Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

C Program for Referencing and Dereferencing (Pointers)

C Program for Referencing and Dereferencing (Pointers)

✅ C Program for Referencing and Dereferencing (Pointers)

#include<stdio.h>
int main()
{
    int x = 10;
    int *ptr = &x;   // Referencing = storing the address of variable 'x' into pointer 'ptr'.

    printf("%d", *ptr);  // Dereferencing = fetching the value stored at that address (here 10).
}
  

πŸ“˜ Explanation:

Pointers in C are used to store the address of variables. - Referencing (&): The & operator is used to get the address of a variable. - Dereferencing (*): The * operator is used to fetch the value stored at that address.

In this program:

  • int *ptr = &x; → stores the address of x into pointer ptr.
  • *ptr → retrieves the value stored at that address (10).

🧾 Sample Output:

10
  

πŸ”‘ Keywords:

C pointers, referencing in C, dereferencing in C, pointer basics, beginner C programs, C interview questions on pointers

πŸ“Œ Hashtags:

#CProgramming #Pointers #Referencing #Dereferencing #InterviewPrep

πŸ” Search Description:

Simple C program to demonstrate referencing (&) and dereferencing (*) using pointers. Explains storing an address and accessing value with sample output.

Comments

Popular Posts

πŸŒ™