Can someone help me with this problem
I need program in c++ ,that can sum number DIGIC COMPLEMENT and RADICAL COMPLEMENT
IF the input is in
DC
1111111111110101
0000000000100010
my output should be
0000000000011000
Please help

Those links didn't work (at least not for me) please input them in a code block (just hit the "Code" button on the top of the editor). Also I have a feeling that your description of your problem will be insufficient. Try to clearly describe exactly what you are trying to do.

Is your problem about two's complement arithmetic?

In his first post he did say that it was about the different compliment systems (he misspelled them but he meant Digit and Radix complements) Digit complement in binary is 1s complement, whereas radix complement in binary is 2s complement. Here is -3 stored in a 3-bit number in both:

Digit complement (1s complement):
original is 011 (3), invert all bits to get 100 (-3)

Radix complement (2s complement):
original is 011 (3), most significant bit is negative so 111 is -1, so 101 would be -3 (by subtracting the 2 bit)

The issue is that I can't access his code. If you can could you post it directly here rather than using pastebin?

@Labdabeta Thanks for the clarification. As I'm not native English myself, I found the OP used a rather "weird syntax"

This is my code, in C, and i have 4 mistakes, can you please check out this code and tell me where are the mistakes. http://imgur.com/M4xQonA
Where it writes "HE" this that is wrong
Thanks

#include <stdio.h>
#include <math.h>
#include <string.h>


`int main() {`
    int a,i=0,y=0,x=0,sum=0,sum1=0,n,prom;
    int b[16],b1[16],zbor[16],new[16];
    char aa,st[10];

//printf("Sistem: ");
    while(y<=2&&(aa=getchar())!='\n') {
        st[y]=aa;
        y++;
    }
    st[y]=0;

//printf("Prv binaren broj: ");
    while(i<20&&(a=getchar())!='\n') {
        b[i]=a;
        i++;
        ++x;
    }
    if(st[0]=='D'&&st[1]=='C') {
        for(i=0; i<x; i++) {
            if(b[i]-48==1) b[i]=0;
            if(b[i]-48==0) b[i]=1;
        }


//printf("Komplement: ");
//for(i=0;i<x;i++)
//printf("%d",b[i]);

//printf("\n");

    for(i=x; i>=0; i--)
        if(b[i]) sum+=pow(2,x-i-1);
    }

    if(st[0]=='R'&&st[1]=='C') {
    for(i=x; i>=0; i--)
        if(b[i]-48) sum+=pow(2,x-i-1);
    }
    i=0;
    x=0;
//printf("Vtor binaren broj: ");
    while(i<20&&(a=getchar())!='\n') {
        b1[i]=a;
        i++;
        ++x;
    }
    if(st[0]=='D'&&st[1]=='C') {
        for(i=0; i<x; i++) {
            if(b1[i]-48==1) b1[i]=0;
            if(b1[i]-48==0) b1[i]=1;
        }


//printf("Komplement: ");
//for(i=0;i<x;i++)
//printf("%d",b1[i]);

    for(i=x; i>=0; i--)
        if(b1[i]) sum1+=pow(2,x-i-1);
    }

    if(st[0]=='R'&&st[1]=='C') {
    for(i=x; i>=0; i--)
        if(b1[i]-48) sum1+=pow(2,x-i-1);
    }

//printf("\n");


//printf("Prv broj - decimalna vrednost: %d\n",sum);
//printf("Vtor broj - decimalna vrednost: %d\n",sum1);

    i=0;
    x=0;
    n=sum+sum1;
    prom=n;
//printf("Zbir: %d\n",n);

    while(n!=0) {
        a=n%2;
        new[i]=a;
        if (a==0) zbor[i]=1;
        if (a==1) zbor[i]=0;
        i++;
        n=n/2;
        ++x;
    }

 if(st[0]=='D'&&st[1]=='C') {
//printf("Komplement: ");
        for(i=x; i>0; i--) {
            printf("%d",zbor[i-1]);
        }
}



if(st[0]=='R'&&st[1]=='C') {
if (prom==42445) printf("overflow");
else{    
for(i=16;i>x;i--)
printf("0");

for(i=x;i>0;i--)
printf("%d",new[i-1]);
}
}

//printf("\n");
    sum=0;
    for(i=x; i>=0; i--) {
        if(new[i-1]) sum+=pow(2,x-i-1);
    }


/*if(st[0]=='D'&&st[1]=='C') {
printf("Komplement: ");
        for(i=x; i>0; i--) {
            printf("%d",zbor[i-1]);
        }
}*/


    printf("\n");


    return 0;
}

Some descriptive comments (in english) would be very helpful. Your variable names are hard to decode. Rename your variables so that they explain what they are, and use comments to describe your code. Also I would strongly recommend splitting your code into functions, for more legibility.

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.