Professional Documents
Culture Documents
Handout C Lecture 1 Part 1 Intro To C 1 AA NEW Date 27-06-2023
Handout C Lecture 1 Part 1 Intro To C 1 AA NEW Date 27-06-2023
Handout C Lecture 1 Part 1 Intro To C 1 AA NEW Date 27-06-2023
Chapter 1. Introduction to C
B.Sc. Mathematics SEMESTER -5
What is C ?
PROGRAMMING IN C
Brief history and origin of Programming Languages.
Unit 1: Introduction to C Introduction to C / The C Character Set
Lecture 1 Part - 1 Constants, Variables and Keywords
Types of C Constants
BY Rules for Constructing Integer Constants
Rules for Constructing Real Constants
Jignasu N. Chauhan Rules for Constructing Character Constants
Head and Associate Professor
Department of Mathematics
Types of C Variables
Shree Manibhai Virani & Smt. Navalben Virani Science College Rules for Constructing Variable Names
An Autonomous College - Affiliated to Saurashtra University
"Yogidham Gurukul“ Kalawad Road C Keywords
Rajkot. Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics,
Virani Science College, Rajkot. 2
ENIAC ( Electronic Numerical Integrator And Computer) ENIAC ( Electronic Numerical Integrator And Computer)
• ENIAC contained 17,468 vacuum tubes, • Took up 1800 square feet (167 m2), and
• 7,200 crystal diodes, 1,500 relays, 70,000 • Consumed 150 kW of power.
resistors,
• This led to the rumor that whenever
• 10,000 capacitors and
the computer was switched on, lights
• Around 5 million hand-soldered joints.
in Philadelphia dimmed.
• It weighed more than 30 short tons (27 t),
• Input was possible from an IBM card
• It was roughly 8 by 3 by 100 feet (2.4 m × 0.9
reader, and an
m × 30 m),
• IBM card punch was used for output.
Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College, Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College,
Rajkot. 5 Rajkot. 6
Information Information
1. Knowledge derived from study, 4. The act of informing or the
experience, or instruction. condition of being informed;
2. Knowledge of specific events or communication of knowledge: Safety
situations that has been gathered or instructions are provided for the
received by communication; information of our passengers.
intelligence or news. See Synonyms at
knowledge. 5. Computer Science Processed,
3. A collection of facts or data:
stored, or transmitted data.
statistical information.
Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College, Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College,
Rajkot. 13 Rajkot. 14
Computer Languages
MEMORY UNITS
Machine Language:- -
A set of instructions for a specific central
processing unit, designed to be usable by a
computer without being translated. Also called
machine code.
An assembly language is a low-level
programming language for a computer, or other
programmable device, in which there is a very
strong (generally one-to-one) correspondence
between the language and the architecture's
machine code instructions.
Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics,
Virani Science College, Rajkot. 19 Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College, 20
Rajkot.
Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College, 21 Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College, 22
Rajkot. Rajkot.
BASIC All Purpose Symbolic For beginners C language (1972) B language (1970)
Instruction Code Denis Ritchie of Ken Thompson of
AT and T’s bell laboratory AT and T’s bell laboratory
ALGOL 60 ALGOrithmic To invent general purpose Powerful, simple Too specific &
Language. language common language & easy to learn language. Less powerful
Programming Language – 1
PL/1
Presentation Prepared by Jignasu N. Chauhan, Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics, Head and Asso. Prof., Department of Mathematics,
Virani Science College, Rajkot. 27 Virani Science College, Rajkot. 28
What is C? History and Origin of C language? What is C? History and Origin of C language?
Developed at AT & T’s Bell Laboratories of USA Thus, without any advertisement C’s reputation
in 1972. spread and its pool of users grew.
Designed and written by a man named Dennis Ritchie seems to have been rather surprised that
Ritchie. so many programmers preferred C to older
In the late seventies C began to replace the more languages like FORTRAN or PL/I, or the newer
familiar languages of that time like PL/I, ALGOL, ones like Pascal and APL.
etc. Popular is because it is Reliable, Simple And
No one pushed C. Easy To Use.
It wasn’t made the ‘official’ Bell Labs language. A language that has survived for more than 3
decades has to be really good.
Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics, Presentation Prepared by Jignasu N. Chauhan, Head and Asso. Prof., Department of Mathematics, Virani Science College,
Virani Science College, Rajkot. 29 Rajkot. 30
Portability
Case Sensitive
Presentation Prepared by Jignasu N. Chauhan, Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics, Head and Asso. Prof., Department of Mathematics,
Virani Science College, Rajkot. 31 Virani Science College, Rajkot. 32
Learning C Language
Steps to learn any language
Constants
Alphabets, Digits,
Special Symbols
Variables, Instructions Program
Keywords
Rules for Constructing Integer Constants. Rules for Constructing Integer Constants.
(a) An integer constant must have at least one digit. The range of an Integer constant depends upon
(b) It must not have a decimal point. the compiler.
(b) It can be either positive or negative. For a 16-bit compiler like Turbo C or Turbo C++
(c) If no sign precedes an integer constant it is assumed to the range is –32768 to 32767.
be positive (Default Sign is Positive) Ex.: 786, +108, -22740, -5702, 0 … etc.
(e) No commas or blanks are allowed within an No Rule Integer
integer constant. 1 Decimal Point Not Allowed
(f ) The allowable range for integer constants is -32768 2 Sign Positive or Negative
to 32767. 3 Default Sign Positive
4 No of Digits At least 1
(g) 2 bytes in memory is allocated for Integer Value.
5 Min Value -32768
6 Max Value +32767
Rules for Constructing Real Constants in Fractional form Rules for Constructing Real Constants in Exponential Form
(Floating Point constants). (Floating Point constants).
Real constants expressed in fractional form: Real constants expressed in Exponential Form :-
Rules:- This form is used if the value of the constant is either too
• A real constant must have at least one digit. small or too large.
In exponential form of representation, the real constant is
• It must have a decimal point.
represented in two parts.
• It could be either positive or negative.
The part appearing before ‘e’ is called MANTISSA,
• Default sign is positive. whereas the part following ‘e’ is called EXPONENT.
• No commas or blanks are allowed
within a real constant. (MANTISSA_part)e(EXPONENT_PART)
Ex.: +3.1415, 589.0, -67.97, -37.0278
Range of Real constants (expressed in fractional form) is
-3.4e38 to 3.4e38
Rules:-
The mantissa part and the exponential part should be
separated by a letter e.
The mantissa part may have a positive or negative sign.
Default sign of mantissa part is positive.
The exponent must have at least one digit, which must
be a positive or negative integer.
Default of sign exponent is positive.
Range of real constants expressed in exponential form is -
3.4e38 to 3.4e38.
Ex.: +97.57e-7, 3.84e6, -0.032e+4, -2.33e-21
Range of Real constants (expressed in exponent form) is -3.4e38 to 3.4e38
Presentation Prepared by Jignasu N. Chauhan,
Head and Asso. Prof., Department of Mathematics,
Virani Science College, Rajkot. 49