Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

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

πŸŒ™