AddressOf Operator in C - C Programming Tutorial 35

Опубликовано: 29 Сентябрь 2024
на канале: ChidresTechTutorials
3,273
56

Notes for You:: AddressOf Operator in C - C Programming Tutorial 35
- is used to get address (or reference) of a variable, or a constant.

Syntax:
&variableName

Example Code:
- C Progrm to display value and address of a variable.

#include <stdio.h>
int main()
{
int a=10, b=20;
printf("Value of a= %d\n",a); // 10
printf("Address of a= %p\n",&a); //0022FF1C
printf("Address of a= %d\n",&a); // 2293532
printf("\n");
printf("Value of b= %d\n",b); // 20
printf("Address of b= %p\n",&b); // 0022FF18
printf("Address of b= %d\n",&b); // 2293528

return 0;
}

Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.


Note: Address of operator is used to
- read a value from the keyboard and assign it to some variable.
- assign address of a variable to a pointer and modify the value in it using pointer.
- pass address of a variable to a function and modify the value in it.
etc.


Example Code:
- C Program to find addition of 2 numbers.

#include <stdio.h>
int main()
{
int a=0, b=0, c=0;

printf("Enter a value for a:");
scanf("%d",&a); // 30
printf("Enter a value for b:");
scanf("%d",&b); // 40
c = a + b;
printf("Value of c= %d\n",c); // Value of c=70

return 0;
}

Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.

=========================================

Follow the link for next video:
   • Pointer Operator in C - C Programming...  

Follow the link for previous video:
   • Comma Operator in C - C Programming T...  

=========================================

C Programming Tutorials Playlist:
-    • C Programming Tutorials  

=========================================
Watch My Other Useful Tutorials:-

Computer Programming Fundamentals Playlist:-
   • Computer Programming Fundamentals  

C Practical LAB Exercises Playlist:-
   • C Practical Programs  

C++ Tutorials Playlist:
   • C++ Tutorials  

=========================================

► Subscribe to our YouTube channel:
   / chidrestechtutorials  

► Visit our Website:
https://www.chidrestechtutorials.com

=========================================
Hash Tags:-
#ChidresTechTutorials #CProgramming #CProgrammingTutorial