Professional Documents
Culture Documents
Let’s start!
#include <stdio.h>
int main(void) {
printf("Hello World!\n");
return 0;
}
Now, let’s understand the structure.
The C Preprocessor is a program that is executed before the source code is compiled.
Directives are how C preprocessor commands are called, and begin with a pound / hash symbol (#). No
white space should appear before the #, and a semi colon is NOT required at the end.
There are two directives in C, namely, include and define. For this section, we will first get to know and
use include.
#include gives program access to a library. It tells the preprocessor that some names used in the program
are found in the standard header file. It causes the preprocessor to insert definitions from a standard
header file into the program before compilation.
For example:
#include<stdio.h> tells the preprocessor to open the library “stdio.h” that contains built-in
functions like scanf and printf.
Every C program has a main function. This is where program execution begins. Note that you cannot
change the name of main.
Braces {} enclose the body of the function and indicate the beginning and end of the function main.
1. Declaration is the part of the program that tells the compiler the names of memory cells in a
program needed in the function, commonly data requirements identified during problem analysis.
C Programming Basics
Example:
int num1, num2, sum;
2. Executable statements are derived statements from the algorithm into machine language and
later executed.
Example:
printf(“Enter 2 numbers: ”);
scanf(“%d%d”,&num1,&num2);
sum = num1 + num2;
printf(“Sum = %d”,sum);
return 0;
Try this!
#include<stdio.h>
int main(void) {
int num1, num2, sum;
printf(“Enter 2 numbers: ”);
scanf(“%d%d”,&num1,&num2);
sum = num1 + num2;
printf(“Sum = %d”,sum);
return 0;
}