advertisements

اليوم بإذن الله سيكون لدينا درس مطول
شوي على الدوال في لغة البرمجة السي
وماهي أنواع هذه الدوال وكيف نعرفها
وما الفائدة من إستخدام هذه الدوال
مسودة الشرح :
FUNCTIONs IN C :
Why We Need Function ?
TYPE : int float double void
>> type name( type parametre1 ,type parametre2 )
{
your code here
return type_variable
}
name()= type_variable;
Methods :
void Name (void) {
your Code ;
}
How To use fuction in C code
declaration > main > definition
Function Example :
argc: argument Count
argv : argument Vector
int main (int argc , char * argv[]) {
return 0 ;
}
>> main(void)
>> main()
void _show() {
printf("Hi There");
}
float sq( float s ) {
return sqrt(s); // square root math
}
#EXPLAIN LOCAL VARIALBLE & GLOBAL VARIALBE
CODE EXAMPLE :
FUNCTIONs IN C : Why We Need Function ? TYPE : int float double void >> type name( type parametre1 ,type parametre2 ) { your code here return type_variable } name()= type_variable; Methods : void Name (void) { your Code ; } How To use fuction in C code declaration > main > definition Function Example : argc: argument Count argv : argument Vector int main (int argc , char * argv[]) { return 0 ; } >> main(void) >> main() void _show() { printf("Hi There"); } float sq( float s ) { return sqrt(s); // square root math } #EXPLAIN LOCAL VARIALBLE & GLOBAL VARIALBE
#include "stdio.h" /* WE CAN HERE DECLARE GLOBAL VARIABLE*/ int Hackshow = 2015; /* Declare Function */ void show() { printf("\nHACKSHOW YEAR : %d\n",Hackshow); printf("\nHello Boss \n"); } int sum(int a , int b) ; /* a & b defined in this scope of function so they are LOCAL VARIABLE */ //int sum (int , int) main (int argc, char * argv[]) { int a=2, b=10; printf("\nThe Name of My Program : %s\n",argv[0]); printf("\nHACKSHOW YEAR : %d\n",Hackshow); show(); sum(a,b); sum(5,3); printf("\nThe result of function : %d\n",sum(5,3)); printf("\nThe result of function(a,b) : %d\n",sum(a,b)); } int sum(int a, int b) { return a+b; }
شرح الفديو :
في أمان الله وحفظه
0 commentaires :
Publier un commentaire