+ 2
Can any one explain functions in easy way ?!!
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!😀
+ 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
0
!!!!!!!!!!!
sir i didn't mean that case ,
0
sir ,that loop not functions 😣
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.
- 1
What did you mean?
- 2
thank u both ,and i'm so sorry for explain in wrong way ☺
- 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.