In Easy Steps Articles

June 18, 2023

What is C Programming?

The C language has been around for quite some time and has seen the introduction of newer programming languages like Java, C++, and C#. Many of these new languages are derived, at least in part, from C – but are much larger in size. The more compact C is better to start out in programming because it’s simpler to learn.

It is easier to move on to learn the newer languages once the principles of C programming have been grasped. For instance, C++ is an extension of C and can be difficult to learn unless you have mastered C programming first.

Despite the extra features available in newer languages, C remains popular because it is versatile and efficient. It is used today on a large number of platforms, for everything from micro-controllers to the most advanced scientific systems. Programmers around the world embrace C because it allows them maximum control and efficiency in their programs.

Programs written 20 years ago in C are still just as valid today as they were back then.

 

The C Compiler

C programs are initially created as plain text files, saved with a “.c” file extension. These can be written in any plain text editor such as Windows’ Notepad application – no special software is needed.

In order to execute a C program it must first be “compiled” into byte code that can be understood by the computer. A C compiler reads the original text version of the program and translates it into a second file, which is in machine-readable executable byte format.

If the text program contains any syntax errors these will be reported by the compiler, and the executable file will not be built.

One of the most popular C compilers is the GNU C Compiler (GCC) that is available free under the terms of the General Public License (GPL).

 

Writing a C program

In C programs, the code statements to be executed are contained within “functions”, which are defined using this syntax format:

data-type function-name ( ) { statements-to-be-executed }

After a function has been called upon to execute the statements it contains, it can return a value to the caller. This value must be of the data type specified before the function name.

A program can contain one or many functions but must always have a function named “main”. The main() function is the starting point of all C programs, and the C compiler will not compile the code unless it finds a main() function within the program.

Other functions in a program may be given any name you like using letters, digits, and the underscore character, but the name may not begin with a digit. Also, there are C keywords that must be avoided.

The ( ) parentheses that follow the function name may, optionally, contain values to be used by that function. These take the form of a comma-separated list and are known as function “arguments” or “parameters”.

The { } curly brackets (braces) contain the statements to be executed whenever that function is called. Each statement must be terminated by a semi-colon, in the same way that English language sentences must be terminated by a period/full stop.

 

Get started with learning C with:

C Programming in easy steps, 5th edition – available now from our online shop in ebook and paperback formats.

£6.99 ebook / £11.99 paperback

By: Mike McGrath
ISBN: 9781840788402

 

 

 

 

C++ Programming in easy steps, 6th edition – available now from our online shop in ebook and paperback formats.

£6.99 ebook / £11.99 paperback

By: Mike McGrath
ISBN: 9781840789713

 

 

 

 

C# Programming in easy steps, 3rd edition – available now from our online shop in ebook and paperback formats.


£6.99 ebook / £11.99 paperback

By: Mike McGrath
ISBN: 9781840789737

 

 

 

 

 

Sign up to our

Newsletter

Our newsletters inform you of new and forthcoming titles, handy tips, and other updates and special offers. You can opt out anytime.

"*" indicates required fields

By In Easy Steps Team

Share

We are sorry to let you go...

Would you mind giving us your feedback or reason of cancelling the subscription?

 

"*" indicates required fields

Hidden
Hidden
Hidden
Reason For Cancellation*
Hidden