### Error

Hello guys! I come to you to ask for help with an error that i do not understand.. if you could help it'd be great..
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950`` `````` #include #include using namespace std; int convertdecimal(int n){ int output=0; for(int i=0;n>0;i++){ if(n%10==1){ output+=pow(2,i); } n=n/10; } return output; } int main(){ int a,b,c,d,a2=0, b2=0, count1=0, count2=0; cin>>a>>b; for(int i=0;a>0;i++){ a2+=pow(10,i)*(a%2); a=a/2; count1++; } for(int i=0;b>0;i++){ b2+=pow(10,i)*(b%2); b=b/2; count2++; } cout<

This program is to calculate(first) the binary version of two variables and if the first digit of the first number is equal to the last digit of the second number we erase them from the numbers.. and so on until you don't erase anything else.... afterwards you put the remaining values back to decimal and display their sum.. The program is not that important as the error is ..

35:35: error: invalid operands of types ‘int’ and ‘__gnu_cxx::__promote_2<int, int>::__type {aka double}’ to binary ‘operator%’
Ifyou could help me solve this i would apreciate it.. thanks in advance!
as far as i know, `pow()` using `double`
Thank you very much for the help! i changed my code a little bit based on what you've made me realise but i got some logical problems...
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253`` ``````#include #include using namespace std; int convertdecimal(int n){ int output=0; for(int i=0;n>0;i++){ if(n%10==1){ output+=pow(2,i); } n=n/10; } return output; } int main(){ int a,b,c,d,a2=0, b2=0, count1=0, count2=0; cin>>a>>b; for(int i=0;a>0;i++){ a2+=pow(10,i)*(a%2); a=a/2; count1++; } for(int i=0;b>0;i++){ b2+=pow(10,i)*(b%2); b=b/2; count2++; } cout<

My biggest problem is that a2 is not updating correctly... If you can help i would thank a lot...
PS i also got one message on the console like"Floating point exception"
Topic archived. No new replies allowed.