History of C
'C' seems to be a strange name for programming languages. But this strange word is one of the most popular languages in today's computers because it is a structured, high-level, machine-specific language. This allows software developers to develop programs where they will be applied without having to worry about hardware platforms.
Importance of C
- It is a powerful language with rich sets of built-in methods and operators that can be used to write complex programs.
- The C compiler combines the skills of an assembly language with the features of a high-level language and is therefore suitable for writing both system software and business packages.
- Programs written in C are efficient and fast. This is due to the variety of data and powerful operators.
- C high portable. This means that C programs written for one computer can be run on another with little or no change. Portability is important if we plan to use a new computer with another operating system.
- The C language is quite suitable for structured programming, so the user has to think about any problems with the modules or blocks of the method.
- Another important feature of C is its ability to expand on its own. A C program is basically a set of methods that are supported by the C library. We can constantly add our own functions to the C library. With the availability of a large number of methods, the task of programming becomes easier.
#include <stdio.h> // header file
int main() // main function
printf("Hello World!"); // shows output
The main Function
main is a part of each C program. C allows different forms of the main statement. The following forms are approved.
- int main()
- void main()
- void main(void)
- int main(void)
Blank pairs of parentheses indicate that the function has no logic. This can be clearly indicated by using the word void inside the first bracket. We can specify the word int or void before the word main. The keyword void means that the function does not return any data to the operating system, which means that the function returns an integer value to the operating system. The last statement of the program must be "return 0" if int is specified. For the sake of simplicity, we use the second form in our programs.
- Every C program requires a main() method. The place to start program execution is the main.
- The execution of a method begins at the opening brace of the method and ends at the corresponding closing brace.
- C programs are written in lowercase letters. However, uppercase letters are used for symbolic names and output strings.
- All words in a program line must be separated from each other by at least one space, or a tab, or a punctuation mark.
- All variables must be declared for their type before being used in the program.
- We must make sure to include header files using #include directive when the program referees to special names and functions that it does not define.
- Compiler instructions include such definitions and compiler instructions that help the compiler compile a program. Does not end with a semicolon.
- The # of the compiler instructions must appear in the first column of the line.
- When braces are used in group statements, make sure there is a finished bracket with the opening brace.
- C is a free-form language and therefore the appropriate form for indentation of different sections can improve the uniqueness of the program.
- A general can be placed almost anywhere space can be displayed. Using appropriate comments in the right place enhances the readability and comprehension of the program and helps users debug and test. Remember to match the symbols / * and * correctly.