Category : add

#include <iostream> #include <cstdlib> #include <cstring> #include <stdio.h> int main(){ char Pbuf8[9]={"01100000"}; char Mbuf4[10]={"01110000"}; int num=0; char Snum[9]="0"; int carry=0; for(int c=7;c>=0;c–){ //Convert a string to a number and add num=(Pbuf8[c]-‘0’)+(Mbuf4[c]-‘0’)+carry; //binary addition if(num==1){ Snum[c]=num; carry=0; }else if(num==2){ num=0; carry=1; Snum[c]=num; }else if(num==3){ num=1; carry=1; Snum[c]=num; } //Convert num to string and store in Snum ..

Read more

**User Enter two Decimal Number then convert in binary and add binary numbers and display decimal.Plz Help me in this case I’m using array. int a[60],b[60],result[50]; array cannot execute properly.** #include <iostream> using namespace std class Binary { private: int m,n,i=0,j=0,carry; int a[60],b[60],result[50]; public: void get_values() { cout<<"Enter first number: "<<endl; cin>>m; cout<<"Enter second number: ..

Read more