Sum and Difference of Two Numbers

Sort by

recency

|

601 Discussions

|

  • + 0 comments
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    
    int main()
    {
    	int a,b;
        float c,d;
        scanf("%d %d\n%f %f\n",&a,&b,&c,&d);
        printf("%d %d\n%.1f %.1f",a+b,a-b,c+d,c-d);
        return 0;
    }
    
  • + 0 comments

    int main() { int a, b; float c, d; scanf("%d %d", &a, &b); scanf("%f %f", &c, &d); printf("%d %d\n", a+b, a-b); printf("%.1f %.1f", c+d, c-d);

    return 0;
    

    }

  • + 0 comments

    int main() { int i_x; int i_y; float f_x; float f_y;

    scanf("%d %d", &i_x, &i_y);
    
    scanf("%f %f", &f_x, &f_y);
    
    int addInt = i_x + i_y;
    int diffInt = i_x - i_y;
    float addFloat = f_x + f_y;
    float diffFloat = f_x - f_y;
    
    printf("%d %d\n", addInt, diffInt);
    printf("%0.1f %0.1f\n", addFloat, diffFloat);
    
    return 0;
    

    }

  • + 0 comments

    int a,b; printf("enter a number"); scanf("%d", &a); printf("enter a number"); scanf("%d", &b); printf("the sum is: %d\n", a+b); printf("the diff is: %d\n", a-b);

    float c,d;
    printf("enter a number");
    scanf("%f", &c);
    printf("enter a number");
    scanf("%f", &d);
    printf("the sum is: %f\n", c+d);
    printf("the diff is: %f\n", c-d);
    
  • + 0 comments
    int a,b;
    float c,d;
    int sum1, diff1;
    float sum2, diff2;
    scanf( " %d %d", &a,&b);
    scanf( " %f %f", &c,&d);
    sum1 = a+b;
    sum2 = c+d;
    diff1 = a-b;
    diff2 = c-d;
    printf( "%d %d \n", sum1,diff1);
    printf( "%.1f %.1f ", sum2,diff2);
    
    
    return 0;
    

    }