Do you want to improve this question?Edit your post to clarify the issue you are trying to resolve by adding details.
Closed 2 years ago.
Two years agoWe wanted to define absolute values in C language, so we defined them as follows:
No matter how many times I compile, there are only errors, so I think something is wrong, but I didn't know what was wrong."I think the first half of the program below, ""int myabs1(intx)"" is correct, but is ""int main(void)"" wrong?"(By the way, I didn't write "inta;a=myabs1();" at first, so I added that, but I still got an error.So I set a=myabs1(x), but it still didn't work.)
int myabs1(intx)
{
intabs;
if(x>=0){
abs = x;
} else {
abs=-x;
}
returnabs;
}
int main (void)
{
inta;
a = myabs1();
printf("x value is:\n";
printf("abs=%d",a);
return 0;
}
In c, creating your own function myabs1(int)
will not run unless you call it correctly.Your myabs1
is designed to take one argument of int
, so
inta=-3;
intb = myabs1(a);
printf("a=%db=%d\n", a,b);
#x
in int myabs1(int x){...}
is an algebraic c whose name is only in
's jargon.
myabs1(-2147483648)
malfunctions...
int myabs1(intx)
a=myabs1();
The myabs1 function takes one argument of type int, but where it is used, there is no argument.
a=myabs1(x), but it still didn't work.
Read the error message properly.
If you don't understand it because it's in English, there is also a translation site
© 2024 OneMinuteCode. All rights reserved.