C programming Introduction
C programming was introduced in the year of 1972. It was developed by Dennis Ritchie at the Bell Laboratory. It became popular in programming because it is fundamental programming in Computer Science. It follows structure-oriented Programming.
C Program Execution consist of 4 Steps:
1. Writing and Editing: Write and edit the source code in the editor. then save the program with the extension .c along with the file name. Like the form as Filename. c
2. Compiling the program: A compiler is used to compile the program. It is used to convert high-level language to low-level language. The low-level language is called byte code. when source code is converted to system-understandable format if there is any syntax error, then it will be notified and stop the conversion until rectify the errors.
3. Linking the Program: After getting the Byte code it will be converted into Executable code. Here byte code will link to the library files. if there is any logical error then it will be notified and stop linking until rectify it.
4. Loading or Running the program: The Executable code is loaded into the machine to display the result as output in user-readable format.
Structure of a c program:
c program consists of a structure using some particular statements. They are:
- Preprocessor Directives
- Global Declaration
- Main function
- local declarations
- other statements
Basic C Program
#inlcude<stdio.h> // Preprocessor directive
void main() //key to start the execution of a program
{
printf(“Hello World! “); // display statement
}
Output: Hello World !
Components of C language:
- comments
- Data Types
- Variables
- constants
- Identifiers
- Key Word
1. Comments in C:
Comments are nothing but Explanations or descriptions of a statement in the program for easy understanding of each instruction.
It can be either Single line or Multi-line comment.
Single-line comments:
It gives an explanation in a single line. To write a single line comment in the program we can use // symbol.
Ex: #include<stdio.h> // preprocessor directive
2. Multiline comments:
It gives a paragraph-type Explanation or description of the program. To write a Multiline comment in the program
we can use /* ———–*/ symbol.
Ex: #include<stdio.h>
/* The pre-processor directives are used to load in the linking state. it establishes communication with library files,
stdio is a standard input-output header file. */
2. Data types:
data types are used to represent the type of data in c programming.
There can be 2 types: Primitive data types and Derived data types.
For More Explanation of Data Types click Here.
Variables and
- Constants,
- Identifiers,
- Key words.