How To Declare Global Function In C Code Example


Example: global and local variables in c

#include <stdio.h>  //local parameters take  precedance  to global//   /* global variable declaration */ int a = 20;   int main () {    /* local variable declaration in main function */   int a = 10;   int b = 20;   int c = 0;    printf ("value of a in main() = %d\n",  a);   c = sum( a, b);   printf ("value of c in main() = %d\n",  c);    return 0; }  /* function to add two integers */ int sum(int a, int b) {     printf ("value of a in sum() = %d\n",  a);    printf ("value of b in sum() = %d\n",  b);     return a + b; }

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools