0% found this document useful (0 votes)
4 views56 pages

Lesson 1 Introduction To C Programming

The document provides an introduction to C programming, detailing its history, features, and applications. C is a general-purpose, machine-independent language developed in 1972, widely used in system applications, embedded systems, and operating systems. It emphasizes structured programming, portability, and code reusability, making it foundational for learning other programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views56 pages

Lesson 1 Introduction To C Programming

The document provides an introduction to C programming, detailing its history, features, and applications. C is a general-purpose, machine-independent language developed in 1972, widely used in system applications, embedded systems, and operating systems. It emphasizes structured programming, portability, and code reusability, making it foundational for learning other programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

PROGRAMMING 1

Introduction to C
Programming
R.BISNAR
PROG1-INSTRUCTOR
What is C Programming
Language? Basics,
Introduction and
History
What is C programming?
❑ is a general-purpose programming language that is
extremely popular, simple and flexible.
❑ It is machine-independent, structured programming
language which is used extensively in various
applications.
❑ was the basics language to write everything from
operating systems (Windows and many others) to
complex programs like the Oracle database, Git,
Python interpreter and more.
What is C programming?

❑is a programming language developed at


AT & T’s Bell Laboratories of USA in 1972.
❑designed and written by a man named
Dennis Ritchie
❑C is a base for the programming. If you know
'C,' you can easily grasp the knowledge of
the other programming languages that uses
the concept of 'C'
IEEE-the best 10 top programming
language in 2018
History of C language
❑ ALGOL –in 1960, Algorithmic Language is the
base or father of programming languages.
Introduced the concept of structured
programming.
❑ BCLP –in 1967 Basic Combined Programming
Language was designed and developed by Martin
Richards, especially for writing system software.
❑ B Programming – in 1970, was introduced by Ken
Thompson that contained multiple features of
'BCPL.' This programming language was created
using UNIX operating system at AT&T and Bell
History of C language
Where is C used? Key
Applications

❑'C' language is widely used in


embedded systems.
❑It is used for developing system
applications.
❑It is widely used for developing
desktop applications.
Where is C used? Key
Applications
❑ Most of the applications by Adobe are
developed using 'C' programming language.
❑ It is used for developing browsers and their
extensions. Google's Chromium is built using
'C' programming language.
❑ It is used to develop databases. MySQL is
the most popular database software which is
built using 'C'.
Where is C used? Key Applications

❑ It is used in developing an operating system.


Operating systems such as Apple's OS X,
Microsoft's Windows, and Symbian are developed
using 'C' language. It is used for developing
desktop as well as mobile phone's operating
system.
❑ It is used for compiler production.
❑ It is widely used in IOT application
Why learn 'C'?
❑as the main language will play an
important role while studying other
programming languages.
❑It shares the same concepts such as
data types, operators, control
statements and many more.
Features of C Program

Structured language
❑It has the ability to divide and hide all the
information and instruction.
❑Code can be partitioned in C using functions or
code block.
❑C is a well structured language compare to other.
Features of C Program
General purpose language
❑ Make it ideal language for system programming.
❑ Itcan also be used for business and scientific
application.
❑ ANSI established a standard for c in 1983.
❑ The ability of c is to manipulate bits,byte and
addresses.
❑ It is adopted in later 1990.
Features of C Program

Portability
❑Portability is the ability to port or use the
software written .
❑One computer C program can be reused.
❑By modification or no modification.
Features of C Program
Code Re-usability & Ability to customize and extend
❑A programmer can easily create his own function
❑It can be used repeatedly in different application
❑C program basically collection of function
❑The function are supported by 'c' library
❑Function can be added to 'c' library continuously
Features of C Program

Limited Number of Key Word


❑There are only 32 keywords in
'C'
❑27 keywords are given by ritchie
❑5 is added by ANSI
Features of C Program

Limited Number of Key Word


❑The strength of 'C' is lies in its in-built
function
❑Unix system provides as large number of C
function
❑Some function are used in operation.
❑Other are for specialized in their application
C program structure
C program structure
❑Comment line : It indicates the purpose of the
program. it is used for increasing the readability of the
program. It is represented as /*……………………………..*/
❑ Pre-processor Directive : #include<stdio.h> tells
the compiler to include information about the standard
input/output library.
❑ Global Declaration: This is the section where variable
are declared globally so that it can be access by all the
functions used in the program. And it is generally
declared outside the function :
C program structure

❑main() : It is the user defined function and every


function has one main() function from where actually program
is started and it is encloses within the pair of curly braces. The
main( ) function can be anywhere in the program but in
general practice it is placed in the first position.
Main Function In Various
Forms
❑main()
❑int main()
❑void main()
❑main(void)
❑void main(void)
❑int main(void)
Steps in C program

Note: close analogy between learning English language and


learning C
language.
How 'C' Works?
Two types of
Programming Language
❑Low Level Language
❑High Level Lnguage
Low Level Language
Are Machine Level and Assembly Level
Language.
❑Machine Level Language computer
only understand digital numbers i.e. in the form
of 0 and 1.
❑Assembly Level Language modified
version of machine level language.
HIgh Level Language

❑ machine independent, means it is portable. The


language in this category is Pascal, Cobol, Fortran etc.
❑ High level languages are understood by the machine.
So it need to translate by the translator into machine
level.
❑ A translator is software which is used to translate high
level language as well as low level language in to
machine level language.
3 Types of translator

❑Compiler
❑Interpreter
❑Assembler
Following is the list of
popular compilers available
online:
❑ Clang compiler
❑MinGW compiler (Minimalist GNU
for Windows)
❑Portable 'C' compiler
❑Turbo C
Basic
Syntaxs
Tokens in C
C program consists of various tokens and a token
is either a keyword, an identifier, a constant, a
string literal, or a symbol.
Tokens in C
For example, the following C statement consists of
five tokens –
Semicolons
❑ 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 */
❑ You cannot have comments within comments and they do not
occur within a string or character literals.
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.
Identifiers
❑ Here are some examples of acceptable identifiers −

mohd zara abc move_name


a_123
myname50 _temp j a23b9
retVal
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.
Whitespace in C
❑ Therefore, in the following statement −
C Keywords

The keywords are also called ‘Reserved words’.


C Character Set
A character denotes any alphabet, digit or
special symbol used to represent information.
Following are the valid alphabets, numbers and
special symbols allowed in C.
❑ Alphabets - A, B, ….., Y, Z a, b, ……, y, z
❑ Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
❑ Special symbols - ~ ‘ ! @ # % ^ & * ( ) _ - + = | \
{}
[]:;"'<>,.?/
Rules for Writing, Compiling and
Executing the C program
❑ C is case sensitive means variable named
"COUNTER" is different from a variable
named "counter".
❑ All keywords are lowercased.
❑ Keywords cannot be used for any other
purpose (like variable names).
❑ Every C statement must end with a ;.
Thus ;acts as a statement terminator.
Rules for Writing, Compiling and
Executing the C program
► First character must be an alphabet or underscore,
no special symbol other than an underscore, no
commas or blank spaces are allowed with in a
variable, constant or keyword.
► Blank spaces may be inserted between two words to
improve the readability of the statement. However,
no blank spaces are allowed within a variable,
constant or keyword.
Rules for Writing, Compiling and
Executing the C program

►Variable must be declared before it is


used in the program.
►File should be have the extension .c
►Program need to be compiled before
execution.
Data types & Placeholders

❑C has 5 basic built-in data types.


❑ Datatype defines a set of values that a
variable can store along with a set of
operations that can be performed on it.
❑A variable takes different values at different
times.
❑ General
form for declaring a variable is:
type name;
Data types & Placeholders
Common data types

❑int - integer
❑char - character
❑float - float number
❑ double - long float
Common data types

❑ Data types refer to an extensive system used for


declaring variables or functions of
❑ different types before its use. The type of a
variable determines how much space it
❑ occupies in storage and how the bit pattern
stored is interpreted. The value of a
❑ variable can be changed any time.
C has the following 4 types of data
types

❑basic built-in data types: int, float,


double, char
❑Enumeration data type: enum
❑Derived data type: pointer, array,
structure, union
❑Void data type: void
Size And Range Of The Different
Data Types
Two Types Of Type Qualifier
In C
❑Size qualifier: short, long
❑Sign qualifier: signed,
unsigned
Other placeholders
Control characters (Escape
sequences)
Certain non printing characters as well as the backslash (\) and the
apostrophe('), can be expressed in terms of escape sequence.
❑ \a - Bell
❑ \n - New line
❑ \r - Carriage return
❑ \b - Backspace
❑ \f - Formfeed
❑ \t - Horizontal tab
❑ \" - Quotation mark
Control characters (Escape
sequences)
❑\v - Vertical tab
❑\' - Apostrophe
❑\\ - Backslash
❑\? - Question mark
❑\0 - Null
Receiving input values from
keyboard
scanf - is a function used to
receiving input from keyboard.
General form of scanf function is :
Receiving input values from
keyboard
►Format string contains placeholders
for variables that we intend to receive from
keyboard. A & sign comes before each
variable name that comes in variable listing.
Character strings are exceptions from this
rule. They will not come with this sign before
them.
Receiving input values from
keyboard
► Note: You are not allowed to insert any
additional characters in format string other than
placeholders and some special characters.
Entering even a space or other undesired
character will cause your program to work
incorrectly and the results will be unexpected. So
make sure you just insert placeholder characters
in scanf format string. The following example
receives multiple variables from keyboard.
Receiving input values from
keyboard

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy