+ 1
See the code and please tell me what is wrong ...........🙏
#include <stdio.h> int odd_even (int num ); int main () { int a ; scanf("%d",&a); odd_even(a); } int odd_even(int num ) { if (num%2==0) { Printf ("even");} else { Printf ("odd");} return (num); }
7 Antworten
+ 1
Mr. Unknown
Ok, now I know what you're referring to.
In the code in your description, we used "num" as PARAMETER of the function. Where "a" is the ARGUMENT.
ARGUMENT are the values/variables that are passed into functions as PARAMETERS.
Here, our argument is "a" and our parameter is "num". Remember that when we passed the "a" to the function, it becomes "num" (so we can use the value inside the function), they have different variable names BUT their value is actually the same.
- - - - - - - - - -
In your second code, it is just the same. "a" is our argument, and the name of our parameter is also "a". The value of the argument "a" is passed into parameter "a" to be used inside the function. Remember that "a" parameter is not referenced to original "a" except if you are manipulating by "reference". https://www.sololearn.com/learn/CPlusPlus/1643/
But it is not a good practice for the argument and parameter to have the same name except if you are manipulating the original variable by Reference.
+ 4
Printf() should be printf(). C is case sensitive.
+ 2
And another thing, you can use "void" instead of "int" as you don't need to return a value since you are just calling the function and not printing or assigning it to a variable.
+ 1
https://code.sololearn.com/cAtu4X3Km0Vb/?ref=app
See the code bit above and also see the code in description ....please tell me why the output of both code bit are not same ?🙄😳😳😳
+ 1
Mr. Unknown I dont see any difference except the wordings. So what is your doubt here?
+ 1
Opps !
Now I understood after executing the code for many times .....
🖥️thanks😊
0
The problem here are the caps on Printf I think, because C language is too much sensitivo, and doesn't allow caps on there