Whitespaces in C
In C programming lines containing white spaces, blank lines, and comments are ignored by the compiler. Whitespace in C is used to describe blanks, newline characters, comments, and tabs.
Whitespace is used to separate parts of a statement from another and it helps the compiler to distinguish the keywords, identifiers, and elements in a statement. It allows us to format our code in a way that makes it easier to understand by programmers and others. In C we are free to use the whitespaces to increase user readability.
Example of Whitespace in C:
int a; // whitespace used to increase readablity and to distinguish elements. string s = "w3wiki";
C Basic Syntax
C is a procedural programming language. It was developed by Dennis Ritchie at the Bell Laboratories in the year 1972. Despite being old C is a very popular language among programmers. It is a very fast language compared to other languages like Python, Java, etc.
Below is the basic syntax structure of the C program:
The basic syntax of the C program consists of the header, main() function, variable declaration, body, and return type of the program.
- The header is the first line in the C program with extension .h which contains macro definitions and C functions.
- Programs must contain the main() function because execution in C programming starts from the main().
- Variable declaration in C is done inside the main function and can be used in the body anywhere but before the main, we can also declare variables which are known as Global variables.
- In the body of the function, we perform operations required inside the function like printing, sum, average, sorting, searching, etc.
- The last part of the C program is the return statement which refers to returning values of the program. If the return type is void then there will be no return statement.
C
// Basic Syntax of C Program #include <stdio.h> // main function int main() { // body printf ( "Hi! This is a basic C program." ); // return statement return 0; } |
Hi! This is a basic C program.