Help please.

Given the numbers a, b, c, d. If a < b < c < d , then replace each number with the smallest, if a > b > c > d , then reduce each number by 40%, otherwise leave the numbers unchanged.

Program Code:

 include <stdio.h> include <windows.h> include <conio.h> include <math.h> main() { float a,b,c,d; if (a < b && b < c && c < d) { b=a; c=a; d=a; } else if (a > b && b > c && c > d); { a=aa*0.4; b=bb*0.4; c=cc*0.4; d=dd*0.4; } printf("a=%fb=%fc=%fd=%f", a,b,c,d); fflush(stdin); getchar(); return(0); } 
  • one
    Where is your code, where are your thoughts, where is reality? .. - Zowie
  • Not clear: do you need help, or do a task for you? If the second, then the wrong address. If the first, then you need to write: "That was done, but that did not work, help me find the error." Like that. - 3JIoi_Hy6
  • and how does it work? - skegg
  • only it is better to stuff all this into the text of the question and format it, and at the same time change the question itself - skegg
  • I see a few mistakes. 1. after the condition block after else if the ";" sign is not needed 2. multiplication operator - *. and it is better to multiply the variables by 0.6 immediately. another question: where do the values ​​of variables come from? - skegg

2 answers 2

 #include <stdio.h> #include <stdlib.h> main () { float a,b,c,d; for (;;) { char str[1024]; printf ("Enter a,b,c,d > "); fflush(stdout); if (scanf("%f %f %f %f",&a,&b,&c,&d) == 4) break; fgets(str,sizeof(str),stdin); } printf ("%f %f %f %f\n",a,b,c,d); } 

An example of entering 4 numbers of type float. Insert at the beginning of your program.

    So what's the problem? The algorithm is very simple. Check the variables for compliance with the specified conditions, and if they are met, take the appropriate action. If not, do nothing. Do you need a code? Write at least something. If there is an error, we will correct and discuss.

    • to the question of initializing variables. examples: 1. int a = 7; 2. int a = c + b; 3. int a; scanf ("% d", & a); it became clearer? - skegg
    • At least one example where in my program it should be inserted. - Pycbka