1. 程式人生 > >C Primer Plus 第6版 Chapter 9 課後程式設計練習

C Primer Plus 第6版 Chapter 9 課後程式設計練習

ex9.1

// ex_9.1
#include <stdio.h>
double min(double, double);

int main(void)
{
    double num1, num2 = 0;
    printf("Enter the first number: ");
    scanf("%lf", &num1);
    printf("Enter the second number: ");
    scanf("%lf", &num2);
    printf("The smaller of %lf and %lf is %lf", num1, num2, min(num1, num2));

    return 0;
}

double min(double a, double b)
{
    return (a < b? a: b);
}

ex9.2