+ 2

Can i use the if statement inside a function?

i need to create a function that return the number of digits that have an int.

20th Jul 2017, 2:33 PM
Randy Rosario
Randy Rosario - avatar
7 ответов
- 2
As others have mentioned it is perfectly fine to use if statements inside a function. If you're looking for an example I've created following script: https://code.sololearn.com/c6F97sc4NgGU Taking a number as input, if the number is above 5 it will output True(1), else False(0).
20th Jul 2017, 2:42 PM
Frederik Stenberg
Frederik Stenberg - avatar
+ 12
ofcouse you can use
20th Jul 2017, 2:39 PM
khadeeja Shamna
khadeeja Shamna - avatar
+ 1
Yes, you can.
20th Jul 2017, 2:38 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 1
You're only able to use if statements in functions, so of course you can!
20th Jul 2017, 2:43 PM
aklex
aklex - avatar
+ 1
Of course you can! Heres an example I just made up void thisFunction(int a){ if(a<18){ cout<<"sorry 18+ only"<<endl; } else{ cout<<"welcome"<<endl; } } int main(){ int a = 16; void thisFunction(a); return 0; }
20th Jul 2017, 4:44 PM
S C
0
ofcos yes...can be used
22nd Jul 2017, 2:25 AM
vincent
vincent - avatar