We use the following steps to create and execute C programs in Windows OS…
Step 2 : We compile code on compiler
...Program finished with exit code 0
Step 3 : Run executable file
Output
X : 5
Y : 13
Following questions raise in my mind
1. We write a code
2. We Compile a code
3. And Run Executable code
Step 1 : We write code on compiler
Example
C:
#include<stdio.h> /* header file */
void function (void); /* declare prototype function */
int main (void) /* Program start from here */
{
int X = 5; /* assign 5 to integer variable X */
printf ( "\n X : %d", X); /* Print value stored in X */
function(); /* call function */
return 0;
}
void function (void) /* Return type : nothing, argument : doesn't pass any parameter */
{
int Y = 12; /* assign 12 to integer variable X */
Y++; /* increment Value of Y by one */
printf ("\n Y : %d", Y); /* Print value stored in Y */
}
...Program finished with exit code 0
Step 3 : Run executable file
Output
X : 5
Y : 13
Following questions raise in my mind
- How does program work during execution time.
- Where does variable's X and Y stored in memory during the execution time.
- How the programmer decide whether variable should be store into heap or stack.
- When does compiler allocates memory for variable at compile time or run time