filmov
tv
C program to swap two numbers using Bitwise Operators // C programming

Показать описание
Hi ,
This program will help you to know how to write a c program to swap two numbers using bitwise operators ,
Logic :
first take two numbers input from user i.e n1 and n2
step 1: Update n1=n1^n2
step 2 : Update n2=n1^n2
step 3: Again update n1 to n1^n2, i.e., n1=n1^n2
This results in swapping as n1 contains new value of n2 and vice versa.
If you like our videos please like, share and subscribe the video.
# interview asked questions in C
# C interview questions
# information technology interview questions
# Computer engineering interview questions
This program will help you to know how to write a c program to swap two numbers using bitwise operators ,
Logic :
first take two numbers input from user i.e n1 and n2
step 1: Update n1=n1^n2
step 2 : Update n2=n1^n2
step 3: Again update n1 to n1^n2, i.e., n1=n1^n2
This results in swapping as n1 contains new value of n2 and vice versa.
If you like our videos please like, share and subscribe the video.
# interview asked questions in C
# C interview questions
# information technology interview questions
# Computer engineering interview questions