How to add two numbers without using the plus operator in c

Posted By: Matpal - January 25, 2012
#include<stdio.h>

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

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

    //sum = a - (-b);
    sum = a - ~b -1;

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

    return 0;
}

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.