And calculating the difference between two numbers

This question and required to achieve a simple function of the difference of two numbers that calculates the input.

Function interface definition:

void sum_diff( float op1, float op2, float *psum, float *pdiff );

Wherein op1 and op2 are two real inputs, Psum and pdiff are calculated and the difference.

Referee test program Example:

#include <stdio.h>

void sum_diff( float op1, float op2, float *psum, float *pdiff );

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

    scanf("%f %f", &a, &b);
    sum_diff(a, b, &sum, &diff);
    printf("The sum is %.2f\nThe diff is %.2f\n", sum, diff);
	
    return 0; 
}

/* 你的代码将被嵌在这里 */

Sample input:

4 6

Sample output:

The sum is 10.00
The diff is -2.00

void sum_diff( float op1, float op2, float *psum, float *pdiff )
{
	*psum=op1+op2;
	*pdiff=op1-op2;
	return;
}
Published 45 original articles · won praise 26 · views 256

Guess you like

Origin blog.csdn.net/Noria107/article/details/104212767