Signup/Sign In
LAST UPDATED ON: SEPTEMBER 17, 2024

Introduction - C Programming Language

C programming language was developed by Dennis Ritchie at AT & T's Bell Laboratories in 1972.

In 1989, the C language was standardized, where C language features were defined, as the 1989 ANSI standard for C, hence it is also called C89, because of the 1989 ANSI standard.

The current latest version of the C language is C17, which was released in June 2018. No new features were added to this version only a few basic corrections were made and some bugs in the C11 version were fixed.

A new standard revision of C programming language is expected in 2023 which will be called C23 or C2x

There are two types of programming languages:

  1. High-level language which is problem oriented

  2. Low-level language which is machine oriented

C Language is a middle-level programming language that has features of both low-level programming language and high-level programming languages.

C language compiler converts the readable C language code into machine instructions.

Versions of C Language

Following are the different versions of the C programming language released till now:

C language Version Year
C89 1989
C99 1999
C11 or C1x 2011
C17 2018
C23 or C2x 2023
History of C language

Latest Version of C

The current version of the C language is C17, which was introduced in 2018. It is supported by all the standard C language compilers, but many compilers still do not support this.

Featurewise C17 is the same as the previous C version C11.

The most widely used version of the C language is still C89, C99, and C11.

The C23 version is expected to launch in 2023.

Why is C Language so popular?

  1. C language is a good language to introduce yourself to the programming world, because it is simple, easy to learn, and covers all the basic concepts of programming.

  2. The scope of C language is limited, so it is good for beginners to start programming.

  3. Initially, C language can be used for writing system-level programs, like designing Operating Systems, OS kernels, etc.

  4. C language can be used to develop simple software, like Text Editors, Compilers, Network Drivers, and many traditional PoS(Point of Sale) software like Restaurant Billing systems, etc.

  5. Some popular applications build using C language are Adobe Photoshop, MySQL Database, Chromium browser, etc.

  6. If you are in college, you can clear college placement interviews by learning C language, and get a job in good service-based companies like TCS, Infosys, IBM, Accenture, etc.

Features of C Language

The following are the features of the C programming language:

  1. It has an easy-to-learn and simple syntax.

  2. It is highly portable. You can write your code on your machine, compile it and run it anywhere.

  3. C is a structured programming language. You can write code in C language using functions, to give your program proper structure.

  4. There are many libraries and header files available in C language and the community for C language is very large.

  5. It is a compiled language.

  6. It is case-sensitive.

Here are all the features of C language listed in detail.

Hello World Program in C

Here is a simple Hello World program in C programming:

#include <stdio.h>

int main() {
	printf("Hello, World!");
	return 0;
}


Hello, World!

The basic program structure for C programs is:

preprocessor directives
macros
global declarations

int main() {

    program logic

}

Write Code in C and execute it

You can write C code in any editor, or you can use Turbo C/C++ which is an IDE for C language.

  1. The programs are stored in files with .c extension.

  2. C compiler is used to compile the C code and generate the object code which is stored in .o extension file.

  3. The object code is then run to get the output.

  4. C language is case-sensitive, so you have to be careful while writing code.

  5. Every line of code in a C program must end with a semicolon (;). If you miss the semicolon, then the compiler will give an error.

  6. If you write anything incorrect while writing a C program, the C compiler will give an error and stop the program execution.

To understand how C programs are compiled, read this - C program compilation

Keywords in C

Keywords are words that have special meanings, stored in the standard installation of C programming language and the C compiler knows what is the meaning of all these keywords.

C programming has 32 keywords.

auto        double      int         struct 
break       else        long        switch 
case        enum        register    typedef 
char        extern      return      union 
const       float       short       unsigned 
continue    for         signed      void 
default     goto        sizeof      volatile 
do          if          static      while

Datatypes and Variables

  1. C language has 5 default datatypes. They are,

    1. int

    2. char

    3. long

    4. float

    5. double

  2. A datatype defines the type of data, values allowed, and what operations can be performed on that data.

  3. A variable is used to store data in it. You can create a variable of any datatype in C language. Once defined the variable can only store the value of that datatype.

Here is a simple C program where we have created a variable and assigned it a value,

#include <stdio.h>

int main() {
    // variable of integer datatype
	int x;
    x = 77;
	return 0;
}

Learn more about data types and variables - Datatypes in C and Variables in C.

Print anything on the console

To print anything on the console or to give output from a C program you can use the printf() function.

  1. The printf function is defined in the stdio.h header file.

  2. So to use the printf function, you have to include the stdio.h header file in your C program.

  3. You can provide any text message to the printf function to print it on the console.

Here is a simple code example,

#include <stdio.h>

int main() {
	printf("Welcome to Studytonight");
	return 0;
}

To learn more about printf function, check this out: C Input & Output

Take user input from keyboard

To take user input in the C program you can use the scanf() function. The scanf function is also defined in the stdio.h header file.

You can use scanf function to take input of a specific type of value.

For example, if you have to take an integer value input, then:

  1. You need a variable of type integer to store the input value in.

  2. You will have to specify a placeholder to inform the scanf function which type of value it should expect.

  3. If you provide a value of some other type, the C compiler will give an error.

Placeholders are special characters for different datatype values to inform the C compiler, which type of value to expect.

1. %d for integer type

2. %c for character type

3. %d for double, etc.

Here is a code example,

#include <stdio.h>

int main() {
    int x;
	scanf("%d", &x);
	return 0;
}

The & operator is used to get the memory address of the variable to store the input value in it.

To learn more about scanf function, check this out: C Input & Output

C Programs to start practice

Here are some simple programs that will help you practice writing code in the C programming language:

Hello World program in C
ASCII value of characters
Program to take user input in C

Here are more C programs for you to practice.

Frequently Asked Questions (FAQ)

Here are some frequently asked questions, that beginners have when they start learning the C language.

1. What is the C language?

It is a computer programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie at Bell Laboratories.

It is a programming language that was developed to do system programming for the operating system UNIX, but later it was used for developing software and programs for daily usage. It is still being used to develop operating systems and for creating system-level programs, by big tech companies (FAANG companies).

2. What are the features of the C language?

C is one of the most popular programming languages. It has many features:

  • Modularity: It allows the reusability of modules. It has header files with readymade functions that you can use.

  • Middle-Level language: It combines both the advantages of low-level and high-level languages. (C arrays, C Pointers, etc.)

  • General-purpose programming language: It can be used to implement any kind of application, just like Python. (Learn Python)

  • Portability: C program can be compiled or executed in any operating system (Unix, DOS, Windows). You can compile the program in Windows and then run it on a Unix machine, it will run without any issue.

  • Powerful programming language: It is a very efficient and powerful programming language. It is best used for data structures and designing system software.

  • C is a case-sensitive language.

C programming language is structured programming language, that needs a compiler for compiling the code into object code (.o extension) which can be executed easily.

We have listed down all the features of the C language in the next tutorial - Features of C Language

3. What is the C language used for?

It is one of the most portable languages and is mainly used for creating system applications that form a major part of Windows, UNIX, and Linux operating systems.

C is a general-purpose programming language. It is used for coding simple software, enterprise applications, games, graphics, and applications requiring calculations, simple software, etc.

4. Where is C used today?

C is used for developing operating systems and Kernel-level programs.

It is used for the production of Compilers. We can develop desktop as well as mobile phone operating systems with the help of C, for example, Android.

5. Who created C language and Why?

C language has evolved from three different structured languages ALGOL, BCPL, and B Language. It uses many concepts from these languages while introducing many new concepts such as datatypes, struct, pointers, etc.

  1. BCPL was developed by Martin Richards, based on which the B language was created by Ken Thompson. And then the B language was the language using which the C language was created.

  2. In 1989, the language was formalized by American National Standard Institute(ANSI).

  3. In 1990, a version of the C language was approved by the International Standard Organisation(ISO), and that version of C is also referred to as C89.

After the C language was accepted worldwide and programmers around the world started using it, soon, to improve C language further, the work on the development of C++ language started.

The idea behind creating C language was to create an easy language that requires a simple compiler (to translate the code from English to binary (0's and 1's that computer understands)) and to enable programmers to write complex programs in a language that is close to English because earlier programmers had to write Machine instructions which were very difficult to remember.