Sum and Difference of Two Numbers

Write a program to use The fundamental data types in c, are int, float, and char. 
C Program
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

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("%0.1f %0.1f",c+d,c-d);
    return 0;
}

Input:

10 4 4.0 2.0
Output:

14 6 6.0 2.0


No comments:

Post a Comment