what is the use of " | " in c language?

char x;
char y;
char z;
z= x | y;
I was wondering what is the use of " | " in c language, does it add bits?

Who is Participating?
ozoConnect With a Mentor Commented:
the result is the bitwise inclusive OR function of its operands.
sarabandeConnect With a Mentor Commented:
the bitwise or means that any bit set in either operand x or y would be set (1) in z.

contrary logical & is bitwise and and z would have only those bits set which were both set in x and y.

logicallayerAuthor Commented:
now it make sense, as I was going through a code of friend and this totally explains it...

thanks for both of you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.