Input Format
The first line contains two integers.
The second line contains two floating point numbers.
Constraints
  •  integer variables 
  •  float variables 
Output Format
Print the sum and difference of both integers separated by a space on the first line, and the sum and difference of both float (scaled to  decimal place) separated by a space on the second line.

hackerrank sum and difference of two numbers problem solution in c programming

Sum and Difference of Two Numbers problem solution in C | HackerRank

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{
 int n, m;
    float a, b;
    scanf("%d %d", &n, &m);
    scanf("%f %f", &a, &b);
    int sum_of_ints = n + m;
    float sum_of_floats = a + b;
    int diff_of_ints = n - m;
    float diff_of_floats = a - b;
    printf("%d %d\n", sum_of_ints, diff_of_ints);
    printf("%.1f %.1f", sum_of_floats, diff_of_floats);
    
    return 0;
}