What does single "&" mean in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What does single "&" mean in C

13th May 2023, 8:20 PM
Kayode Ojoawo
Kayode Ojoawo - avatar
6 Answers
+ 13
Depending on the context, & symbol could represent bitwise AND operator, and it could also represent address-of operator. It depends where and when the symbol is used ... int n = 12345; // here & represents bitwise AND operator printf( "<n> = %d\n<n> & 5 = %d\n", n, ( n & 5 ) ); // here & represents address-of operator printf( "Address of <n> = %p\n", &n ); (Edited to add code example)
14th May 2023, 1:00 AM
Ipang
+ 7
But what does "&&" mean in C
13th May 2023, 9:44 PM
Kayode Ojoawo
Kayode Ojoawo - avatar
+ 6
& is AND bit operator. It check bit by bit if two of them are 1. Else, result of the bit is 0. Example: 12 = 00001100 (In Binary) 25 = 00011001 (In Binary) Bit Operation of 12 and 25 00001100 & 00011001 ________ 00001000 = 8 (In decimal) Example taken from programiz
13th May 2023, 9:22 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 6
&& is used in if blocks, for example. It is the logic AND int num1 = 5; int num2 = 9; int num3 = 3; num1 < num2 -> true num1 < num3 -> false (num1 < num2) && (num1 < num3) true AND false -> false This operator returns true if the first and the second blocks are true Did you understand?
13th May 2023, 9:52 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 5
Ipang really? Post your example so the answer will be more complete
14th May 2023, 6:55 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 3
Bitwise and
15th May 2023, 4:48 AM
G Ramya