السلام عليكم،
اولا" اشكركم على هذا المنتدى الرائع واتمنى ان تقبلوني كتلميذ وصديق لكم ،واعذروا كتابتي الركيكه لان اهلي ادرجوني في مدارس وجامعات انجليزيه بحت. :wacko:
وسؤالي، عندي كود معين واعرف معظمه كيف يعمل ولكن الاشكال عندي في فهم اخر عمليه في ال function singTheSong!
#include <stdio.h>
void singTheSong(int numberOfBottles)
{
if (numberOfBottles == 0) {
printf("There are simply no more bottle of beer on the wall.\n");
} else {
printf("%d bottle of beer on the wall. %d bottle of beer.\n", numberOfBottles, numberOfBottles);
int oneFewer = numberOfBottles - 1;
printf("Take one down, pass it around, %d bottles of beer on the wall.\n", oneFewer);
singTheSong(oneFewer); // This function calls itself
printf("Put a bottle in the recycling, %d empty bottles in the bin.\n", numberOfBottles);
}
}
int main(int argc, const char * argv[])
{
singTheSong(99);
return 0;
}لماذا عندما يصل البرنامج الي هنا يبتدء المتغير numberOfBottles بالأزدياد وبرغم انه لا يوجد اي عملية جمع؟ لاماذا لا يقف البرنامج عندما يكون numberOfBottles صفر؟؟
printf("Put a bottle in the recycling, %d empty bottles in the bin.\n", numberOfBottles);ومرة" اخرى اعذروا اسلوبي في التعبير.
