C Programming Tutorial for Electrical Engineer – Part-1
C Programming Tutorial for Electrical Engineer: Part-1
Being familiar with C programming will make us to do Arduino based projects and Embedded projects more understandable and easy…
Being an Electrical Engineer you may not be an expert in writing the C code. But you must be atleast familiar with understanding the flow of coding… ie, What the program does and how it works….
In a series of posts we will learn C Programming step by step….
Before going to learn the C Language, which is the most important and basic language of Computer Software, lets see the layers of computer software.
From the below diagram we can easily understand the hierarchy of software development.
- Initially, the information in the computer were processed using bits (0’s and 1’s).
- Then, slowly the machine level language was developed. This uses binary digits (Combinations of bits).
- Then Assembly language evolved. Assembler was used to decode assembly language instructions and execute.
- After that the procedure oriented programming languages were developed. One of that was C language.
- To overcome the disadvantages of Procedure oriented languages, object-oriented languages came into picture. One of such object-oriented programs is CPP.
C Programming Language:
Procedure (Structure) Oriented Programming was popular in 1980’s as it bridges the gap between machine language and conventional high level languages.
- Due to its flexibility, C is especially used for System Programming.
- It contains certain library functions and enhanced basic instruction sets.
- User can write their own library functions also.
- We know that, any program that is written in a high level language should be translated to the machine level language, then only it can be executed further.
- This process is called compilation or interpretation.
- To perform this process, every high level language should have a built-in compiler or interpreter.
- C also has various C compilers and interpreters. Whereas C interpreters are less effective.
History of C language:
- C was developed in 1970’s by Dennis Ritchie at Bell Telephone Laboratories,Inc.
- It was developed from two earlier languages: BCPL and B.
- Many C compilers and interpreters were written using which many applications were developed and used.
- Also some applications used commercially that are written in other languages were rewritten in C and used due to the portability and efficiency of C.
- The C language also have other advantages.
Advantages of C Language:
- Integrity: Accuracy of calculation.
- Clarity: Readability of the program.
- Simplicity: C language is as simple as possible and consistent with overall program objectives.
- Efficiency: C language has high execution speed and efficient memory utilization.
- Modularity: In C language,the programs are broken into small modules.
Those modules can be enables the programmers to easily understand that program.
- Generality: C language is as general as possible, within reasonable limits.
Drawbacks of C Programming;
- When the program becomes larger in size, the structured programming approach fails to show desired results. Especially, it is difficult to free bugs and is not easy to maintain reusable programs.
- The problem is viewed as a sequence. Hence to make any change to the program it should be done at first i.e before starting the program. In case of large-sized programs,it is a tedious process to make changes in entire program.
- While using a data for a long program, certain data are declared as global. Function may have their own data as local. In such case, it is difficult to identify which data (Either global or local) is used in certain function.
- Procedure oriented program doesn’t model any real world problems. Because their functions are action oriented and not really correspond to the elements of the problem.
- There is a problem of memory corruption due to the usage of pointers which we will see in later.
- Some errors can be found only at the run time so that the program has to be analysed after all it finishes mostly.
Thanks for Reading….
In coming future posts, we will learn various conditional statements of C language like for loop, If..else loop, while loop etc