+ 2

Can any one explain functions in easy way ?!!

6th Nov 2016, 6:52 PM
malak
8 Respuestas
+ 10
Function is a particular task or work Consider you want to wash your car. You wash your car whenever you have free time. You can do it at home using "specific/specialized " equipment. You can also go to a CAR WASH PARLOR. At home, You need specific/special EQUIPMENT. You WASH the CAR yourself. At parlor, They already have equipments. You enter with a CAR in the parlor. You get a CLEAN CAR when you exit. You don't need to do it yourself. The CAR PARLOR here is a function which has the parameter of type CAR and return value CAR. summarizing, AT PARLOR, CarParlor ( Car Audi ){ int elements; //Code to CLEAN a car called Audi Audi = CLEAN; return Audi; } and at home int main(){ Car Audi; int buy_equipments; //Code Audi= CLEAN; //work //use car //work int buy_equipments; //code Audi = CLEAN; //work //groceries int buy_equipments; //code Audi = CLEAN; } So instead of writing a code again and again use functions and be happy!😀
6th Nov 2016, 7:25 PM
Paul Kabira
Paul Kabira - avatar
+ 4
you can chunk your program into mini programs called functions. they can optionally take any number of values and/or a return a value. this helps you organize your code in smaller pieces
7th Nov 2016, 1:16 AM
Alex
Alex - avatar
0
!!!!!!!!!!! sir i didn't mean that case ,
6th Nov 2016, 7:07 PM
malak
0
sir ,that loop not functions 😣
6th Nov 2016, 7:18 PM
malak
0
You wrote 'functions' but ok. Loops are the same. If the loop is true the loop does something. If the loop is false the loop stops.
6th Nov 2016, 7:27 PM
TheLastCookie
TheLastCookie - avatar
- 1
What did you mean?
6th Nov 2016, 7:08 PM
TheLastCookie
TheLastCookie - avatar
- 2
thank u both ,and i'm so sorry for explain in wrong way ☺
6th Nov 2016, 7:34 PM
malak
- 4
Functions can be true or false. if (x == 0) { cout << "Yes"; } else { cout << "No"; } If x = 0 then say Yes. If x is not 0 then say No.
6th Nov 2016, 7:05 PM
TheLastCookie
TheLastCookie - avatar