Wednesday, 9 December 2015

C program: subtraction of two numbers without using minus operator

#include<stdio.h>

int main(){
   
    int a,b;
    int sum;

    printf("Enter any two integers: ");
    scanf("%d%d",&a,&b);

    sum = a + ~b + 1;

    printf("Difference of two integers: %d",sum);

    return 0;
}

Sample Output:

Enter any two integers: 7 3
Difference of two integers: 4

No comments:

Post a Comment