IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Functions ❯ Sorting Three Numbers
<06.12>
// program to sort three numbers #include <stdio.h> // arranges arguments in ascending order // smp and lgp are addresses double variables. // variable pointed to by small contains the smaller // variable pointed to by big contains the larger void order(double *small, double *big) { double temp; // temporary variable for the swap if (*small > *big) { temp = *small; *small = *big; *big = temp; } } int main (void) { double num1, num2, num3; printf("Enter three numbers separated by blanks > "); scanf(" %lf %lf %lf", &num1, &num2, &num3); // Orders the three numbers order(&num1, &num2); order(&num1, &num3); order(&num2, &num3); printf("The numbers in ascending order are: %.2lf %.2lf %.2lf\n", num1, num2, num3); return (0); }
Hergestellt in Deutschland / Made in Germany
Enter three numbers separated by blanks > 34.76 26.1 24.01 The numbers in ascending order are: 24.01 26.10 34.76
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.