Home Education C Programming-Learn with Examples absolutely FREE

C Programming-Learn with Examples absolutely FREE

C Programming Language is a very powerful general-purpose language. However, the development of C Language results in the development of several other languages. Also, in today’s world of technology, it still holds the position.

It is one of the languages which is used in the development of Adobe Softwares, Operating Systems, Hardware drivers, etc.

learn-C-programming

‘C’ is a bit old language but it’s the first choice if you are going to learn programming because learning ‘C’ language will cover all the basics, advanced fundamentals. Thus, you will be able to learn other languages easily and fastly.

Below these topics will land you on the content:

  1. History of C Programming
  2. Structure of a ‘C’ Program
  3. The Main Function
  4. Using Expressions
  5. Conclusion
  6. QnA

Let’s see some Features:

c-programming-language-tutorial

History of ‘C programming Language’

The C Language was developed by Dennis Ritchie in 1972 at AT&T Bell Laboratories, USA (now known as Bell Laboratories).

The development of ‘C’ Programming Language was a result of the development of several programming languages, which can be called ‘The Ancestors of C’.

These were Algol 60, Combined Programming Language(CPL), Basic Combined Programming Language(BCPL), and B.

Algol 60

( By an International Committee,1960 )

CPL

( At Cambridge and London University, 1963 )

BCPL

( Martin Richards at Cambridge University, 1967 )

B

( Ken Thompson at Bell Laboratories, 1970 )

C

( Dennis Ritchie, Bell Labs, 1972 )

There were many Computer languages before the development of ‘C’, however, the problem was every language was developed just for a specific purpose. For example, COBOL was developed for business applications and FORTRAN was developed for mathematical applications.

Therefore the need was to develop a programming language that can handle any type of task and support a variety of applications. This was the reason for the development of the C programming language.

What’s the scope for ‘C programming language’ in today’s world?

Frankly speaking, JAVA is taking up. Nowadays, ’C’ shares less than 7% because the world now needs OOP(Object Oriented Programming) and also needs an update from the perspective of future needs. But, C programming language is still most used for hardware programming and OS development. Also, C language is a boost to your career if you are starting your career in Programming.

Structure of a ‘C’ Program

Let’s see the Basic Format(Structure) of a ‘C’ program is:

Documentation Section

Link Section

Macro definition Section

Global Declaration Section
Function Section

main()
{
  Declaration Part

  Execution Part
}

Subprogram Function

-Function_1
-Function_2
.
.
.
-Function_N
User Defined Functions

Structure Explanation :

c-programming-structure

Let’s get details of what the diagram is actually about:

Generally, the program is divided into 3 parts:

First Section:

  • Documentation Section :

It’s just a comment section which is optional, it is used to convey information about the program.

  • Link Section :

The link section is used to link predefined header files and the other user files. ( Section to import files )

  • Macro Definition Section :

This section defines all symbolic constants.

  • Global Declaration Section :

As the name suggests ‘Global’ which means used anywhere, the variable that you declared in this section can be used anywhere in the program.

Middle Section:

  • Function Section :

Here we have to declare a function if we are going to use it.

  • Main Section / Code :

This section is the coding section where you have to write code for the program.

Last Section :

  • Subprogram Section :

However, this is the last section because some programs use the functions while some don’t. By the way, you can say that this section is only reserved for Functions.

The Main Function- C programming language 

It is the region where you are going to code. The program starts with the ‘main’ keyword, before the ‘main’ keyword you have to declare what is going to be returned after the end of the program.

Hello_world_program

For example, if your code is going to return an integer or a boolean (Check ‘What is Programming page, to get more details on various Data Types) then you have to use that data type or if it’s not then you have to use ‘void’ keyword

Explanation using Code :

 // This is an Addition program.
#include<stdio.h>
void main()
{
 int a=1, b=2, c;
 c=a+b;
 printf(c);
}

Here, in the above code, we used void because the code doesn’t go to pass/return anything outside the main function. Void means ‘null’ or ‘nothing’.

Let’s understand the whole example I used above:

// & /** */ are comments. Check ‘What is Programming’ for more details.

#include<stdio.h> is link, including it to our code gives functionality to print/display, get input etc.

Generally, #include is the same as the word ‘Import’, ‘< >’ is the reference where we have to put the address/file.  stdio.h stands for Standard Input-Output and .h for Header file, stdio is the file name and the .h is the location, in other words, if you open the ‘C’ software folders, then you will get a header folder, in that folder, you will find stdio file, which contains the code for Input, Output, etc.

void main() referred that the main function is not going to return any value.

{ } these are the curly braces in which we are going to write our code/user-defined code.

int a=1, b=2, c; is the declaration statement of variables( a,b,c ).

Here we used int (Integer) because all variables are going to store numbers. Although, we can also write the statement as:

int a=1;
int b=2;
int c;

You can see at the end of the statement we used semicolon( ; ).

We assigned a as 1, b as 2, but c is empty because c is going to hold the result of a+b.

Note: We have to declare variables before using them.

printf() is the inbuilt function that is declared in stdio.h and it prints/displays the text/variable value inside it. In the above program, we print the value of c is 3.

C Program Development Steps :

  1. Write the programs.

First, we have to write the program on the editor.

  1. Compile the source code/program.

The source code is passed to the preprocessor to check whether there are any syntax or segment errors. If all is OK then the program is converted in Machine code(Low level) called object code.

  1. Link the compiled code.

Here the Machine code is processed and creates a file with .exe extension.

  1. Execute the program.

Once the executable file is created then you are able to run or see the program results.

Rules for naming a Variable:

  1. A variable should start with a small case letter.
  2. Meaningful names should be given.
  3. No spaces and symbols should be used, except ‘_’, but not in first and last place.

Ex.:- 

basic_sal is correct.

_rollnum is incorrect.

studentname_ is incorrect.

No_of_years is correct.

c-programming-tutorial

Using Expressions

An expression is a combination of variables, constants, operators, and brackets.

For example,

10

a + b

sum + 5

(a – 10)

(a – 10) *25

These are all expressions.

We can also use these(below) types of expressions in programming:

FormulaExpression
a+b_____

c
(a+b)/c
3xy+y3*x*y+y
s=ut2s=u*t*t
a+b   e___ * _c-d     f(a+b)/(c-d)*(e/f)

Conclusion

You completed the very Basics of C. I can’t say you are ready to develop some Professional Apps because what you learned is just a percent, you have to learn more. So learn and practice daily.

Let’s go further and learn the Fundamentals with easily understandable examples. :- C Programming in Details with Easy Examples

QnA

Q1. Are C programming and C++ programming same?

No. The syntax and the compilation look the same but the major difference is C programming is a procedural language and C++ is an Object-Oriented language.

Q2. Is C programming object-oriented?

Nope. C is a procedural language.

Q3. Where C programming is used?

It is used for game developments, Adobe software, and hardware programming.

Q4. What software should I use for C language?

You can use Turbo C, Codeblocks, etc.

Q5. Is C programming used in Embedded systems?

Yes.

Q6. What are the built-in(in-built) functions and User functions?

In-built functions are the functions that are available in the directories(provide ready-made) and used everywhere. The User’s functions are the functions that you write and also be used wherever you want.

RELATED ARTICLES

List of Best Kitchen Hobs in India 2021 with a Detailed Guide

Indian Houses are always incomplete without a kitchen, and one of the essential appliances for any kitchen is a kitchen hob. Whether...

Best Gaming Laptops in India That You Can Buy in 2021

Presently, laptops play a crucial role in everyone's life. Due to advancements in technology, nowadays all individuals use laptops for various purposes....

Best Wi-Fi Modem for BSNL Broadband – Detailed Comparison

In this information age, we all firstly depend on the internet very much for day to day tasks. Almost every business has...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

List of Best Kitchen Hobs in India 2021 with a Detailed Guide

Indian Houses are always incomplete without a kitchen, and one of the essential appliances for any kitchen is a kitchen hob. Whether...

Best Gaming Laptops in India That You Can Buy in 2021

Presently, laptops play a crucial role in everyone's life. Due to advancements in technology, nowadays all individuals use laptops for various purposes....

Best Wi-Fi Modem for BSNL Broadband – Detailed Comparison

In this information age, we all firstly depend on the internet very much for day to day tasks. Almost every business has...

Rice Companies in India

Rice, unlike most other cereals, we consume it as a whole grain. No one is there who is not fond of rice....

Recent Comments