History of C
Programming
Language
Mr. Angelito G. Salac
ICT Instructor
What is C Programming?
• C programming is a general-purpose,
procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie
at the Bell Telephone Laboratories to develop the
UNIX operating system. C is the most widely
used computer language. It keeps fluctuating at
number one scale of popularity along with Java
programming language, which is also equally
popular and most widely used among modern
software programmers.
Why to Learn C Programming?
• C programming language is a MUST for students
and working professionals to become a great
Software Engineer specially when they are working
in Software Development Domain. I will list down
some of the key advantages of learning C
Programming:
Why to Learn C Programming?
• Easy to learn • Structured language
• It produces efficient • It can handle low-level
programs activities
• It can be compiled on a
variety of computer platforms
Facts about C
• C was invented to write an operating system called UNIX.
• C is a successor of B language which was introduced around the early
1970s.
• The language was formalized in 1988 by the American National
Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System Programming
Language.
• Most of the state-of-the-art software have been implemented using C.
• Today's most popular Linux OS and RDBMS MySQL have been written
in C.
C Programs
• A C program can vary from 3 lines to millions of lines and it
should be written into one or more text files with
extension ".cpp"; for example, hello.cpp. You can use any
other text editor to write your C program into a file.
• This tutorial assumes that you know how to edit a text file
and how to write source code inside a program file.
• If you want to set up your environment for C programming
language, you need the following two software tools available
on your computer, (a) Text Editor and (b) The C Compiler.
The C Compiler
• The source code written in source file is the human readable
source for your program. It needs to be "compiled", into machine
language so that your CPU can actually execute the program as
per the instructions given.
• The compiler compiles the source codes into final executable
programs. The most frequently used and free available compiler is
the GNU C/C++ compiler, otherwise you can have compilers
either from HP or Solaris if you have the respective operating
systems.
• The following section explains how to install GNU C/C++ compiler
on various OS. We keep mentioning C/C++ together because GNU
gcc compiler works for both C and C++ programming languages.
Hello World Example
A C program basically consists of the following parts:
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
Hello World Example
• The first line of the program #include <stdio.h> is a
preprocessor command, which tells a C compiler to
include stdio.h file before going to actual compilation.
• The next line int main() is the main function where the
#include <stdio.h> program execution begins.
int main() { • The next line /*...*/ will be ignored by the compiler and it
has been put to add additional comments in the program.
/* my first program in C */ So such lines are called comments in the program.
printf("Hello, World! \n"); • The next line printf(...) is another function available in C
return 0; which causes the message "Hello, World!" to be
displayed on the screen.
}
• The next line return 0; terminates the main() function
and returns the value 0.
• You have seen the basic structure of a C program, so it
will be easy to understand other basic building blocks of
the C programming language.
Tokens in C
Semicolons
• In a C program, the semicolon is a statement terminator. That is, each
individual statement must be ended with a semicolon. It indicates the
end of one logical entity.
Comments
•Comments are like helping text in your C program and they are ignored
by the compiler.
•They start with /* and terminate with the characters */ as shown below
−
•/* my first program in C */
Tokens in C
Identifiers
• A C identifier is a name used to identify a variable,
function, or any other user-defined item. An identifier starts
with a letter A to Z, a to z, or an underscore '_' followed by
zero or more letters, underscores, and digits (0 to 9).
• C does not allow punctuation characters such as @, $, and
% within identifiers. C is a case-sensitive programming
language. Thus, Manpower and manpower are two different
identifiers in C.
Tokens in C
auto else long switch
Keywords break enum register typedef
The following list
case extern return union
shows the
reserved words in char float short unsigned
C. These reserved
words may not be const for signed void
used as constants continue goto sizeof volatile
or variables or any
other identifier default if static while
names. do int struct _Packed
double
Tokens in C
Whitespace in C
• A line containing only whitespace, possibly with a
comment, is known as a blank line, and a C compiler
totally ignores it.
• Whitespace is the term used in C to describe blanks,
tabs, newline characters and comments. Whitespace
separates one part of a statement from another and
enables the compiler to identify where one element in a
statement, such as int, ends and the next element
begins.