Hi,
I would like to write a program which takes a double as parameter and has the following functionality:
If the passed value is <= 0 | 0 is returned
If the passed value is > 0 | the passed value is returned unchanged
I have written this code:
But somwhere is a problem because i can not compile the code.Code:#include <stdio.h> double rel(double n1) { { if (n1 <= 0) n1 = 0; else if (n1 > 0) n1 = n1; } return n1; } double read_data() { double i; scanf("%lf", &i); return i; } double main() { double i = read_data; printf("%.2f", double i, rel(double i)); }
Thanks for your help