Addition between two numbers

/*Addition of two numbers without using '+' operator*/
#include<stdio.h>
int main(){
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d",a-(-b));
}

/*Addition of two numbers without using arithmetic operators*/
#include<stdio.h>
int main(){
        int a,b;
        scanf("%d%d",&a,&b);
        while(b<0){
            a--;
            b++;
        }
        while(b>0){
            a++;
            b--;
        }
        printf("%d",a);
}

No comments:

Post a Comment

Total Pageviews