Program in C++ and C to call function through if statement.
C
CPP
#include<stdio.h> int isEven() { int n; printf("Enter a number :-"); scanf("%d",&n); return n; } int main() { if(isEven()%2==0) printf("Even number."); else printf("Odd number."); return 0; }
#include<iostream> using namespace std; int isEven() { int n; cout<<"Enter a number :-"; cin>>n; return n; } int main() { if(isEven()%2==0) cout<<"Even number."; else cout<<"Odd number."; return 0; }
Output:-
0 Comments