i tried to figure out the wrong here but i donnu why it ignore the part of string converting .. b2 is always equal to 0 in the output ..
here is my code

#include<iostream>
#include<string>
#include<sstream>
#include<bitset>
using namespace std;
void encrypt(long num);
int main()
{
    int N, M;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> M;
        encrypt(M);
    }
    return 0;
}
void encrypt(long num){
    int b1, b2, en;
    bitset<10> x1(num);
    b1 = x1.count();
    stringstream x;
    x >> num;
    string s = x.str();
    bitset<10> x2((string)s);
    b2 = x2.count();
    en = num ^ (b1*b2);
    cout << b1 << " " << b2 << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.