Professional Documents
Culture Documents
a. Directives
Syntax: #define
Macro
This macro defines constant value and can be any of the basic data
types.
b. Main function ()
Every C-programs needs to have the main function. Each main function
contains 2 parts. A declaration part and an Execution part. The declaration
part is the part where all the variables are declared. The execution part
begins with the curly brackets and ends with the curly close bracket. Both
the declaration and execution part are inside the curly braces.
int main(void)
{
int a=10;
printf(" %d", a);
return 0;
}
c. User functions
createSquare () function
color () function
A
n example to add 2 integers
#include <stdio.h>
int main()
{
int n1,n2,sum;
scanf("%d %d",&n1,&n2);
printf("sum = %d",sum);
return 0;
}
{
int result;
result = a+b;
}
d. Execution stages
#include <stdio.h>
intmain(){
printf("Hello C Language");
return0;
2) Expanded source code is sent to the compiler which compiles the code and
converts
it intoassembly code.
4) The object codeis sent to linker which links it to the library such as header files.
Then it is
converted
intoexecutable code. A simple.exe file is generated.
5) The executable codeis sent to the loader which loadsit into memory and then
it is executed
. After execution, output is sent to the console.