Upward communication
In upward communication, the called function sends data back to the called function without receiving any data from it. A good example of this type of communication is, when the called function reads the data from the keyboard, the data needs to be passed back to the called function.
int main(void){int a;int b;..upFun(&a, &b);...} //mainvoid upFun(int*ax, int*ay){*ax=23;*ay=8;return;} //upFun
To send data from the called function to the calling function:
-we need to use a symbol ‘&’ (address) in front of the data variable when we call the function.-we need to use the * symbol after the data type when we declare the address variable.-we need to use the * in front of the variable when we store data indirectly.
//Function Declaration
void upfun(int *ax, int*ay)int main(void){// Local Declarationsint a;int b;//StatementsupFun(&a, &b);printf(“%d\n”,a,b);return 0;} //mainvoid upFun(int *ax, int *ay){//Statement*ax=23;*ay=8;return;} //upFun
Bidirectional communication:
In upward communication, the called function sends data back to the called function without receiving any data from it. A good example of this type of communication is, when the called function reads the data from the keyword, the data needs to be passed back to the called function.
int main(void){int a;int b;...biFun(&a, &b);...} //mainvoid biFun(int* ax, int* ay){*ax = *ax+2;*ay = *ay/*ax;return;} //biFun
//Function Declaration
void biFun (int* ax, int* ay);int main(void){int a=2;int b=6;//Statements...biFun (&a, &b)...return 0;} //mainvoid bifun(int* ax, int* ay);{*ax = *ax+2;*ay = *ay/*ax;return;} //biFun
Social Plugin