When it comes to programming, the first programming language we can all thought of, and have heard many times being from a programming background is C. Let's start with this basic C programming language and taking one topic at a time, we will cover everything about C programming. So, brush up your PC's and laptops and start to code with us.
Before actually going with the C programming, we need to know some interesting facts about C and one of the fact is what is C and why it is so important?
C is a middle-level programming language because we can make high-end software using C as well as it can access hardware directly.Many Core libraries, MySQL and Oracle Databases , many Device Drivers, many web browsers include major portion of C coding. Many well-known operating systems like UNIX and LINUX are written in C programming language.
Thus, it is clear from the above applications that how necessary is it to know about C and not only get the theoretical knowledge but also get to code in C and then make a real project on C as well.
So, for understanding how C come up as the most popular language, let's go into a quick overview of C programming. The first programming language developed was BCPL (Basic Combined Programming Language) by Martin Richards which is although not in use, have created a large impact as the programming world in which we are living today is all because of BCPL only after which B programming language was made by Ken Thompson in 1969.
Father of C programming and linux
After three years of constant work, Ken Thompson and Dennis M. Ritchie made the C programming language and it was initially not made for general-purpose but was developed for making the UNIX Operating System. This language was developed in AT&T‟s Bell Laboratory of the USA in 1972.
After getting a brief insight into C, we have to clear our concepts about certain keywords like Hardware, RAM, Processor, Hard Disk, Software, Operating System, File, Folder
and we have covered all these things in previous blogs, so do check out that blogs to get a better insight into upcoming topics.
Now, let's begin with the actual working of a C program which is also known as the software process of C programming.
Firstly, we make a C file by giving an extension of .c to any text file. Then, the preprocessor processes the file and includes the header files in it. Then, the work of compiler comes into play and then the library files get added to the object code created during compilation by linker. Then, that object file is transferred to the loader and the program finally gets included and the output is shown.
Smallest Unit in C programming: Identifiers
We know how a file is made and how the program gets executed. Now, let's begin with the actual C programming language. Starting with any language, we always start with the smallest unit of that language to understand everything steps by step. As we have alphabets as the smallest unit in the English language, we have identifiers as the smallest unit in C programming language.
Now, what is an identifier? It is actually divided into three parts which define it well.
1. Constants: According to maths, anything whose value doesn't change in any conditions is constants. Similarly, the concept of constant in C also remains the same. The constants have further division as there are two types of constants in C programming, primary and secondary.
• Primary Constants: Integer(2, 3, 1000, 100000), real(2.34, 5.777, 9.00) and character(a, b, '7', 'h' any number can also be a character but it has to be in single quotes) constants are three types of primary constants that exist in C.
• Secondary Constants: Array, Strings, Union, pointers all are secondary constants of which we will be talking in coming blogs.
2. Variables: Just like in maths variables in programming are the same , means the value of variables can be modified as many times as we want throughout the whole program , but there is slight difference which is , in programming , a variable can be defined as the name of memory location in RAM , which we fix to use in future with that variable name.
Rules for defining a variable name:
▪No variable can start with a number but we can add numbers after an alphabet.
▪ A variable can start from any alphabet, or underscore(_)
▪ A variable can be of infinite length
3. Keywords: These are a set of predefined words which are already defined in the C programming language. We have 32 keywords in C programming and the list is as shown below in the image.
As in the common language, what we actually mean by instructions? Giving commands, right? And making the other person do the work. Similarly, in C instructions are the program statements through which we give commands to the computer to perform that specific task.
There are four types of instructions that we give through our program:
□ Data type declaration instructions: As clear from the name itself, these instructions are used to declare variables and their data type says everything about the nature of variables created.
Ex- int a: We are giving instructions to the computer to create a variable an of int data type.
float b: We are giving instructions to the computer to create a variable b of a float data type.
char c: We are giving instructions to the computer to create a variable c of a char data type.
□ Input-Output Instructions: These instructions are used to get input from the users through the printf(" ") function and output is shown through scanf(" ") function which will talk about in upcoming blogs.
□ Arithmetic instructions: The type of instructions used to perform some arithmetic calculations like addition, subtraction, multiplication, etc. are called arithmetic instructions.
Ex- c = a + b, 8*7, 9-6 etc.
□ Control Instructions: These instructions are used to accelerate the working of the program or to make decision in program through the use of different loops(for, while, do-while), if-else and switch statements.
So, let's sum up what we learnt today and how we have improved our knowledge in C programming language. Starting with what is C and why should we learn this language, we go through the history of this language. Then, we started with how the C program is executed and is the smallest unit we have in this language. After getting some deep knowledge about identifiers, we finished our blog with a little insight about instructions.
Let's meet in the next blog where we will dig deeper and get thorough with our basics of C programming and learn how to write a simple C program.
Keep learning! Keep coding!