+ 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); }

14th Jan 2021, 2:19 AM
RD:programmer
RD:programmer - avatar
7 odpowiedzi
+ 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.
14th Jan 2021, 1:12 PM
noteve
noteve - avatar
+ 4
Printf() should be printf(). C is case sensitive.
14th Jan 2021, 2:23 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 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.
14th Jan 2021, 2:47 AM
noteve
noteve - avatar
+ 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 ?🙄😳😳😳
14th Jan 2021, 5:18 AM
RD:programmer
RD:programmer - avatar
+ 1
Mr. Unknown I dont see any difference except the wordings. So what is your doubt here?
14th Jan 2021, 5:57 AM
noteve
noteve - avatar
+ 1
Opps ! Now I understood after executing the code for many times ..... 🖥️thanks😊
14th Jan 2021, 1:10 PM
RD:programmer
RD:programmer - avatar
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
15th Jan 2021, 10:43 AM
Jorge Hdez Schez
Jorge Hdez Schez - avatar