+ 1

Is this code is valid for oddeven by using function in c

#include <stdio.h> int oddeven(int a){ if(a%2==0) printf("even"); else printf("odd"); return; } int main(){ int a; printf("enter a number"); scanf("%d",&a); oddeven(a); return 0; }

15th Jul 2023, 6:26 AM
Swapnil Banerjee
Swapnil Banerjee - avatar
3 Answers
+ 5
It depends on what the task is and you haven't described the details here. Your question is therefore unclear.
15th Jul 2023, 6:35 AM
JaScript
JaScript - avatar
+ 4
Swapnil Banerjee , Your code is valid, just need few changes for look effective. 1:- Remove first `return;`this is not valid/correct `return`statement. 2:-The function is declared as an `int` function, it does not return an integer value. This will show warning or error when you compiling the code. for fixed the issues change return type of the `oddeven()` function to `void`. See this code... https://code.sololearn.com/ck1334GYgiXP/?ref=app
15th Jul 2023, 7:33 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 3
What you think? Swapnil Banerjee
15th Jul 2023, 7:10 AM
A͢J
A͢J - avatar