First C Program
Programming in C language is very simple and before starting the program of C language, we need to learn how to write, compile and run the c program.
C program consists of the following parts -
- Preprocessor Commands - which tells a C compiler to include stdio.h and other required header files before going to actual compilation.
- Functions - the main function where the program execution begins.
- Variables - A declaration of variable tells the compiler where and how much storage to create for the variable.
- Statements & Expressions - C program statements consists of various tokens i.e. a keyword, an identifier, a constant, a string literal, or a symbol. Each statement must be ended with a semicolon. The semicolon is a statement terminator.
- Comments - Comments between /* */ symbol will be ignored by the compiler
Let us look at a simple code that would print the words "My First C Program" :
#include <stdio.h> | → Preprocessor Commands |
/* Start of the program */ | → Comments line |
int main() | → Main Function - start of the program |
{ | → Open curly brace as the start point |
printf("My First C Program"); | → Statement |
return 0; | → Return statement |
} | → Closing curly brace marks the end |
ADVERTISEMENT