C++ Program to Perform Addition Operation Using Bitwise ...

文章推薦指數: 80 %
投票人數:10人

Bitwise operators are used to perform bitwise operations. That implies the manipulation of bits. Some of the bitwise operators are bitwise ... Home CodingGround Jobs Whiteboard Tools Business Teachwithus TrendingCategories DataStructure Networking RDBMS OperatingSystem Java iOS HTML CSS Android Python CProgramming C++ C# MongoDB MySQL Javascript PHP SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho C++ProgramtoPerformAdditionOperationUsingBitwiseOperators C++ProgrammingServerSideProgramming Bitwiseoperatorsareusedtoperformbitwiseoperations.Thatimpliesthemanipulationofbits.SomeofthebitwiseoperatorsarebitwiseAND,bitwiseOR,bitwiseXORetc.Aprogramtoperformadditionoperationusingbitwiseoperatorsisgivenbelow−Example LiveDemo#include usingnamespacestd; intmain(){   intnum1,num2,carry;   cout<>num1;   cout<>num2;   while(num2!=0){    carry=num1&num2;    num1=num1^num2;    num2=carry<<1;   }   cout<>num1; cout<>num2;Afterthat,additioniscarriedoutusingawhileloop.ItinvolvesusingthebitwiseAND,bitwiseXORandleftshiftoperators.Thecodesnippetisgivenbelow−while(num2!=0){   carry=num1&num2;   num1=num1^num2;   num2=carry<<1; }Finally,thesumisdisplayed.Thisisgivenbelow−cout<



請為這篇文章評分?