C Programming Language
Key Terms
Program – an organized list of instructions that, when executed
causes the computer to behave in a predetermined manner.
Programming Language – is vocabulary and set of grammatical
rules for instructing a computer or computing device to perform
specific tasks.
2 Elements of Programming Language
Syntax - refers to the rules that specify the correct combined sequence used to
form a correctly structured program using a given programming language.
Semantics - is a term for the ways that data and commands are presented.
Key Terms
Programming – is the implementation of logic to facilitate specified
computing operations and functionality.
Programming language semantics and syntax are used when constructing
a program.
Requires knowledge of application domains, algorithms and programming
language expertise.
Compiler - is a special program that processes statements written
in a particular programming language and turns them into machine
language or "code" that a computer's processor uses.
Key Terms
Integrated Development Environment (IDE) –
A graphical user interface (GUI)-based workbench designed to aid a
programmer/developer in building software applications or programs with
an integrated environment combined with all the required tools at hand.
Lists of Programming Languages
JavaScript
Python
Java
C / C++
PHP
Swift
C#
Ruby
Objective – C
SQL
What is C Language?
is a general-purpose, procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie, an American
computer scientist at the Bell Telephone Laboratories to develop the
UNIX operating system.
It is known as middle level language because it has the power of a
lower level language and easy syntax like high level language.
What is C Language?
High Level Language (HLL) - is any programming language that
enables development of a program in a much more user-friendly
programming context and is generally independent of the computer's
hardware architecture. They are referred to as "closer to humans.“
Low Level Language - is a programming language that deals with a
computer's hardware components and constraints. It is referred as a
computer native language.
Why Learn C Language?
C is a Middle-Level Language - The middle-level languages are
somewhere between the Low-level machine understandable assembly
languages and High-Level user friendly languages.
Helps to understand the fundamentals of Computer Theories
Fewer Libraries - C programming language has fewer libraries in
comparison with other high-level languages.
Library – is a collection of precompiled routines that a program can use.
Execution Time
Embedded Programming
IDE Setup
Turbo C
Optional IDE
Code Blocks
Environment Setup
Turbo C - is an integrated development environment (IDE) and
compiler for programming in the C language. A tool for writing
programs in the C programming Language.
It was developed by Borland Software Corporation and first
introduced in 1987.
Structure of C Programs
A C program basically consists of the following parts :
Preprocessor Commands / Header Files
Functions
Variables
Statements & Expressions
Comments
Structure of C Programs
A simple code that would print the words “Hello World”.
Structure of C Programs
Let us take a look at the various parts of the above program:
The first line of the program #include <stdio.h> is a preprocessor command or
header files, 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 program execution begins.
The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
The next line printf(...) is another function available in C 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.
Header Files
The files that are specified in the include section is called as
Preprocessor Command or commonly known as Header Files.
These are precompiled files that has some functions defined in them.
Header File is given a file extension of .h
C Programs or source files is given a file extension of .c
Main Function
This is the “Starting Point” of a program.
When the file is executed, the start point is the
main function.
Main function is compulsory for any C program.
Comments
Comments are like helping text in your C
program and they are ignored by the compiler.
2 Types of Comments
Single Line Comments (//)
Multi Line Comments (/* */)
Functions
Functions - is a block of code that performs a specific task.
2 Types of Functions
1. Standard Library Functions
The standard library functions are built-in functions in C programming. These
functions are defined in header files. For example,
The printf(..) is a standard library function to send formatted output to the
screen (display output on the screen). This function is defined in the stdio.h
header file.
Hence, to use the printf(..) function, we need to include the stdio.h header file
using #include <stdio.h>.
Functions
2. User – Defined Functions
Functions which are defined by the user at the time of writing
program. These functions are made for code reusability and for
saving time and space.
Return Function
This is the “Ending Point” of a program.
Compile & Execute C Programs
1. Write a C program
Compile & Execute C Programs
2. Save the program using F2 or File > Save in the menu bar. The file
extension should be “.c” Ex. HelloWord.c
Compile & Execute C Programs
3. Compile the program using Alt + F9 or Compile > Compile in the
menu bar.
Compile & Execute C Programs
4. Press CTRL + F9 to run the program or Select Run > Run in the
menu bar.
Compile & Execute C Programs
5. Press ALT + F5 to view the output of the program at the screen.
Reference
Tutorialspoint.com – C Programming Language
Introduction to C Programming Language – Sanjay Joshi (Slideshare)