#include #include #include #include using namespace std; int main() { FILE *f; int a,b=0; f=fopen("data.txt","r"); FILE *g; g=fopen("dataout.txt","w"); if(f==NULL) printf("File opening error"); fscanf(f,"%d",&a); while(a!=0) { b=b*10+a%2; a=a/2; } int sum=0; while(b!=0) { sum=sum+b%10; b=b/10; } fprintf(g,"%d",sum); return 0; }