C Intro
C Intro
Reference Book:
Final: 50
10 marks MCQ
40 marks subjective
Dennis Ritchie
Importance of C
• Robust language whose rich setup of built in functions
and operator can be used to write any complex
programs.
• Programs written in c are efficient due to several
variety of data types and powerful operators.
• The C complier combines the capabilities of an
assembly language with the feature of high level
language. Therefore it is well suited for writing both
system software and business package.
• C is portable language , meaning that c programs
written for one system can be run on another system,
with little or no modification.
Importance of C
• C language is well suited for structured
programming, this requires user to think of a
problems in terms of function or modules or
block. A collection of these modules make a
program debugging and testing easier.
• We can continuously add our own functions to
the library with the availability of the large
number of functions.
Characteristics of C
• Integrity: accuracy of the calculations
• Clarity: overall readability of the program, with particular
emphasis on its underlying logic
• Simplicity: keeping things as simple as possible, consistent
with the overall program objectives
• Efficiency: execution speed and efficient memory utilization
• Modularity: breaking down into a series of identifiable
subtasks; enhances the accuracy and clarity of program
• Generality: making programs as general as possible
C FUNDAMENTAL
Identifiers, Constants & Variables
• Identifiers
– Identifiers are names that are given to various program
elements, such as variables, functions and arrays.
– Identifiers consist of letters and digits, in any order, except
that the first character must be a letter .
– upper- and lowercase letters are permitted, though common
usage favors the use of lowercase letters for most types of
identifiers.
– The underscore character ( _ ) can also be included, and is
considered to be a letter .
– An underscore is often used in the middle of an identifier .
An identifier may also begin with an underscore, though
this is rarely done in practice
– Have standard predefined meanings in C
Identifiers, Constants & Variables
• Keywords can be used only for their intended purpose; they
cannot be used as programmer-defined identifiers
– Fixed meaning, cannot be changed
– Basic building block
– Lowercase
Identifiers, Constants & Variables
• int: integer quantity 2 bytes or one word
• char: single character 1 byte
• float: floating-point number 1 word (4 bytes) a
decimal point andor an exponent)
• double: double-precision floating-point number (i.e.,
more 2 words (8 bytes))
Identifiers, Constants & Variables
• Constants
– Fixed values
– Does not changes during execution of program
– Numeric constant – Integer (decimal, octal, hexadecimal)
and Real
– Character constant
• Single character constant
• String constant
• Backslash character constant
Identifiers, Constants & Variables