A program on C language without using subtraction operator is done by taking the numbers 2's complement and then add it to another number.
#include<stdio.h>
int main(){
int a,b;
int sum;
int complement=0;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
complement= ~b+1; //2's complement of b
sum = a + b;
printf("Difference of two integers: %d",sum);
return 0;
}
Sample Output:
Enter any two integers: 7 4
Difference of two integers: 3
0 Comment(s)