Академический Документы
Профессиональный Документы
Культура Документы
C LANGUAGE
CHAPTER 18
C LANGUAGE
SPECIAL ABOUT C
It
BASIC STRUCTURE OF C
BASIC STRUCTURE OF C
DOCUMENTATION SECTION
IT CONSISTS OF A SET OF COMMENT LINES GIVING
THE NAME OF THE PROGRAM, THE AUTHOR AND OTHER
DETAILS
LINK SECTION
PROVIDES INSTRUCTION TO THE COMPILER TO LINK
FUNCTIONS FROM THE SYSTEM LIBRARY.
DEFINITION SECTION
DEFINES ALL THE SYMBOLIC CONSTANTS.
GLOBAL DECLARATION VARIABLES
THIS IS MEANT FOR DECLARING GLOBAL VARIABLES
PROGRAMMING IN C
CREATING A PROGRAM
COMPILING A PROGRAM
CREATING A PROGRAM
A
With
The
the extension of .c
COMPILING A PROGRAM
cc
<filename> - to compile
The
Object Program
Ex:
Pay.o
After
Otherwise
code
IN
CONSTANTS
Constants in C refer to fixed values
that do no change during the execution
of a program.
There are two types of constants they
are
Primary Constants
Secondary Constants
C constants
Primary Constants
Secondary Constants
Integer Constants
Array
Real Constants
Pointer
Character Constants
Structure
String Constants
Union
Enum
INTEGER CONSTANTS
REAL CONSTANTS
This constant will represent by no. containing
fractional parts.
Real constants are also called as floating points.
Real constants can be positive or negative.
example 34.5, 0.0073, -0.67
Real Constants can be expressed in Exponential
or Scientific Notation.
In Exponential form, the real constant is
represented in 2 parts
REAL CONSTANTS
CHARACTER CONSTANTS
This Constant contain a single character.
It should be mentioned within a single
quotes
examples 4, y
4 is not same as 4
Each character constant has its own
integer value known as ASCII
example a has as ASCII value of 97
STRING CONSTANTS
IT is a sequence of characters
enclosed in double quotes
VARIABLE
A data name that is used to store a
data value.
it may be chosen by the programmer
in a meaningful way in order to reflect
its function or nature in the program.
some valid variable names are
Average, height
CHARACTERISTICS OF
VARIABLES
It should always begin with a letter
length of variables should not exceed
8 character
variables are case sensitive
AVERAGE is not same as Average or
average.
same variable name should be used
throughout the program.
CHARACTERISTICS OF
VARIABLES
DATA TYPES
Integral type
Floating type
Integral type
Integer
Character
float
double
Long double
int idnumber;
int transaction_number;
int __my_phone_number__;
float its4me;
double VeRyStRaNgE;
float myCash;
int CaseNo;
int CASENO;
int caseno;
STORAGE CLASS
AUTO
STATIC
STORAGE CLASS
OPERATORS
operators
Relational operators
Logical operators
ASSIGNMENT OPERATORS
Increment & Decrement Operators
Conditional Operators
Bitwise Operators
Arithmetic operators
Operator
+
Meaning
Addition or
unary plus
Subtraction or
unary minus
Multiplication
Division
Modulo division
Relational operators
Operator
<
<=
>
>=
==
!=
Meaning
Is less than
Is less than or equal to
Is greater than
Is greater than or equal
to
Is equal to
Is not equal to
Logical operators
Logical
ASSIGNMENT OPERATORS
Ex:
a=b-5
++n;
n++
--n; n--;
++n is equal to n=n+1; (n+=1)
--n is equal to n=n-1; (n-=1)
Ex: n=4;
Ex: n=4;
x=++n;
o/p -> x=5
x=n++;
o/p -> n=5
CONDITIONAL OPERATORS
?,
Bitwise Operators
Bitwise
operations
Not suitable for float & double
& - Bitwise AND
! - Bitwise OR
^ - Bitwise XOR
<<- Shift Left
>>- Shift Right
~ - Bitwise NOT (Complement)
RELATIONAL EXPRESSION
An
TRUTH TABLE
OP 1 OP - 2 Value of
the
expressio
n
Op-1 &&
op-2
1
op-1 || op-2
I/O Functions
Scanf
Input function
Printf
Output function
#include
< stdio.h>
name> = getchar( );
( a);
NO:235 TABLE
FORMATTED I/O
TABLE
EX:
Thank
you