Here we are going to get introduction to C programming in a practical manner.
Photo by Fabian Grohs on Unsplash
A program is a set of instruction given to a computer to solve a problem.To start programming, the first thing we need to know, is the problem. The next step is to brainstorm the problem and find an algorithm which can solve that problem.An algorithm is a sequence of steps followed to solve a problem. A good algorithms has some features like-
- It is short, simple and unique.
- It has a output for every possible legal inputs.
- It can handle any exception if arises in a program.
Now getting towards the topic introduction to C programming
We need to know the basic syntax of C programming which is as follows-
Syntax:
Here,
Example:
Output of above program is 33.
In the above program we can see,
Syntax:
Here,
- Documentation section is very similar to multiple line comments, everything written between /*...*/ is ignored by the compiler.
- Preprocessor Directive in C are special program which process our codes before compilation is done.
- main() function is a very essential part of every program. In C, the program execution begins from the main() function.
- body of programs includes the steps we perform to solve a problem
Example:
Output of above program is 33.
In the above program we can see,
- How we can write useful information in Documentation Section
- In above program there is no global variable, all three variables num1, num2 and sum are variable of main() function
- printf() is used to print the output on screen
- %d within " " tells the compiler to print the variable sum in format of integer number.