0% found this document useful (0 votes)
165 views

C nOTES

The document provides steps and information for developing a computer program. It begins by outlining the initial steps as: 1) creating an algorithm, 2) making a flow chart, and 3) writing code in a light-level language. It then discusses preparing input, compiling code, debugging errors, and testing the program. Additional details are provided on C language as a middle-level language and its importance, character sets, keywords, identifiers, and types of constants in C programming.

Uploaded by

Sunil Trivedi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

C nOTES

The document provides steps and information for developing a computer program. It begins by outlining the initial steps as: 1) creating an algorithm, 2) making a flow chart, and 3) writing code in a light-level language. It then discusses preparing input, compiling code, debugging errors, and testing the program. Additional details are provided on C language as a middle-level language and its importance, character sets, keywords, identifiers, and types of constants in C programming.

Uploaded by

Sunil Trivedi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 16

Steps for developing Programmer

Algorithm
Flow Chart
Code into Light level Languages
Input Preparation
Compilation
Corrections
Test Process

The first step in lives while developing a programme is Algonthm to represent the paper.
The second step for developing a programme is called flow chatting. Flow chating
means the digramaticaug representation of comp programe following are the symbols
ureel in flow charts

Start/End , I/O , Procuring , Precision , Looping

The next step for developing a computer programming to writing code into ligh
level language. That mean writing a progrmme into a ligh level language, using prison
Ted format for programme. It mean write instruction 8 Command which are regavd for
that programme in ligh level language.
Next step is preparing output. The next step is compilcation that mean to conveat
the ligh level language into machine level language with the usr of compiler. Of there are
errors it display that errors which are accused by you & the last steps is – Test proscenia
exsiccation of programme.

Note :- C Language is middle level language tecaure it has Characteristics of ligh level
language & level language.

Introduction to ‘C’ Programming */


C seem a strong name for programming language but this Strong sounding
language is one of the most popular language to day ‘C’ was an offspring of a Basic
combined programming language (BCPL) developed in lobos at Cambridge University it
is also called as ‘B’ language this language is modified by Derma is Ratline at Bell
laboratories in 1972 The new language was developed along with Unix operating System
is strongly associated = Unix for many years ‘C’ was used mainly in aeaelemic
environment But eventually with the relearse of ‘C’ compilers for Commericial use.
Today ‘C’ is running under a no of operationg system inducing Ms Dos. Windowas.

Importance of ‘C’
Programme written in ‘C’ are efficient & fast. This alue to its rariety of data types &
powerful operations.
It is many time faster than basic.
There are only 32 keywords & its strength lies in its built in functions.
Several Standred functions are available ‘C’ can be used for developing a
programme ‘C’ to lightly portable to mean that ‘C’ Programming written for one
computer can be run on another well -------------------- or no modification.

Character set in C Programme *


The Characters that can used to form words now & erpression depends upon the
Computer on which the program is run. However a Subset of a charaete is available that
can be used on most personal micro, mini & mainframe comp. The charaeten in ‘C’
programming are grouped into the fallowing catatonic.
Letters, 2) Digits, 3) Special Chanauten, 4) White Spaces.
Letters – Uppercase A to Z
Lowarcase a to z
Digit - 0 – 9 (decimal)
Special Characters.
White Spaces – 1) Blank Space 2) Horizontal Tab 3) Camiage Teturn 4) New Line 5)
Form Feed.
Trigraph Characters
Many non English keywords or Characters mentioned in the above table
‘C’ intendances the concept of paragraph sequences to provide a way to enter certain
characters that are not available on some keyboard. Each trihgraph sequence consists of
3 Characters.
(?? Followed by another characters. )
Eg.
Trigraph seq. Tramlation

??= #
??( [
??) ]
??< {
??> }
??!
??/ \
??’ ^
??- ~

‘C’ Language is a middle Level


Language because it has a characteristic of ligh level language & low level language
ANSI – American national standred instars.
* Special Characters

, Comma
. Paved
; Semicolon
?
: Apostrophe
“ Quotation mark
! Exclamation
Vertical bar
/ F. slash
\ B. slash
~ Tilde
_ Underscore
$ Dollar sign.
%
# Hash
& Amper Sand
^ Canet
* Asteric
__ Minus
+ Plus
< Les than
> Greater than
( Left parenthesis
) Right parenthesis
[ Left bracket
] Right bracket
{ Left brace
} Right brace

The keywords & identifiers in ‘C’


Every C word is classified as keyword or an identifier.
All keywords have fix meaning and this meaning cant be change keywords serve as basic
bulling blocks for programme & statements.
All the keywords must be written in bwercare. The keywords in ‘C’ are listed as
below.
1) Auto 2) Break 3) Case 4) Char 5) Const 6) Continue 7) Default 8) Do 9)
Double 10) Else 11) Erne 12) Extern 13) Flat 14) For 15) Go to 16) If 17) Int. 18) Long
19) Register 20) Return 21) Short 22) Signed 23) Size of 24) Static 25) Stat 26)
Switch 27) Type def ? 28) Union 29) Using 30) Void 31) Volatile 32) White.

Identifier
Reefers to the name
Of variables, function & arrays. There are user defined names consist of sequence of
letter & digit with a letters as a first character both uppercase and lowercase letters are
permitted although lower case letters are commonly. The under score character is also
permitted in identifier.
Constants
Constants in C refers to fixed values that do not change during the execution of
programme C supports several types of const. They are as

Constant

Numeric Const Character Const

Integer Float 333333333


Const Const 3
333333333333333 3333333
33
3
Integer Const
An integer Const rafters to a seq. of digit there are 3 types of integer namely decimal
octal hexadecimal intger const is a set of digit 0 – 9 preceded by an optional - or +
sign valid eg – of decimal int const are
123 – 321, O + 78

Note :- Spaces, Commas & non digit Char are not permitted bet digits.

Octal constant
An octal int const consist of any combination of digit from the set of 0 – 7 with a leading
‘o’ zero eg – 0,3,2,7, 0, 0,4,5,3.
* Hexadecimal Constant
A seq. of digits preceded by 02 or ox is Consider as hexadecimal integer. They
may also include alphabet A – F or a – f following are the eg.
0x2
0 x 1F
0 x bcd.
we rarely use octal and hexadecimal nos in programming.

A) Real Constant / float const.


Integer numbers are inadequate to represent quantities that are very continuously, such as
distances, lights, temp prize & so an. These quantities are represented by no. Containing
fractional part like 17.548 such no ar called real or flouting point const further eg of real
consts are 0.05, -0.75, 435.36, + 247.0. These nos are shown in decimal notation having
a whole number followed by a decimal point & the fun part it is possible to omit digits
before the decimal point of digits after the decimal point i.e. 215 , ’95 , . - .71 +.5 are all
the real numbers a real no may also be expressed in exponent ion or scientitic notation.

Single Character Constant


A single Character constant contains a single character enclosed within a pair of quote (‘
’) eg – of character constants are ‘5’ / ‘a’ / ‘ ; ’ / ‘ ’
Note :- that the character const ‘5’ is not same as 5. the last const is a blank space.
Character const have integer value known as ASCII value.

C) String Constant
A string constant is a set of characters enclosed within a double quote “ ” The
character may be letters, numbers sepelial characters & blank space eg.- one “helo” /
“1987” / “ well done “ / eeg “?……!” / “5+3” / “X”
Remember that a character const ‘X’ is not equvalant to string const “X” further a
single character string const doc not have an equralant integer value while.
Character strings are often use to built meaning – ful programmes.

D) Back slash constant

‘C’ supports some special -----


Shash const that are used in output funn . The list of Back slash character const are as
follows.
‘ \ a’ __ audioable alart / bell
‘ \ b’ __ Back space
‘\f’ __ Form feed
‘\r’ __ Carriage retain
‘ \ w’ __ Vertical tab
‘ \ n’ __ New line
‘\’ __ Single quote
‘\“’ __ Doable quote
‘\?’ __ Question marts
‘ \\ ’ __ Back slash
‘\0’ __ null

Variables
A available is a data name may be used to store a data values unlike const that remain
changed during the execution of a programme a variable may take different. Values at
different times during execution.
A variable name can be choosen by the programmer in a mearingful way so as to
refrect its funnor nature in the programme. Some eg. Of such name are – Average.
Light
Total
Counter_1
Class_ Strength
As mentaioned eariar verable name may consist letters, digit & the undersore
characters, Sub. To the following condn-
They must begging – a letters.
Some sys. Permit underscore as the first character.
ANSI recognizes a length of 31 Characters however the lengh should be eight character
since only the first 8 characters are prated as significant by many compilers.
The upper case & lower case are significant ie. the veiable Total, is not same as total or
TOTAL.
The variable name should not be a keyword.
Blank space is not allowed.

DATA TYPES
‘C’ language is rich in its data types. Srorage representation & machin instruction to
handle constants differ from machine to machine. The vaiety of data types available
allow the programmer to select the type appropriates to needs of the application as well
as the machine.
‘C’ supports 4 classe of data type.
Primary data types.
User – defined data types.
Derived data types.
Empty data sete.

Primary / fundamental data – types


All ‘C’ Compiles support 4 fundamental data types. Namly integer (Int),
character (Char), floating point (float), double precisisn floating point (floas), Many of
them also offer extended data types such as long integer (Long - int), & Long – doable.

Primary data Types

Integer Character

Signed type unsigned type


Int ----//--- int Signed Charas
Short int ---//---- int unsigned Char.
Long int ---//---- int

Floating Point Types

Float Double Long double


Size & Ranges of data types on a 16 bit machine

Types Size (bits) Range


Cnar or signed char 8 - 128 to 127
Unsigned char 8 - 0 to 225
Int or signed int 16 - 32, 768 to 32, 767
Unsigned int 8 0 to 65535
Short int or sigred
Unsigned short int 8 0 to 225
Long int / sigred C. Iint 32 - 2,147,483,648, to
2,147,483,647
unsigrd L. Int 32 0 to 4, 294, 967,295
32 3.4E – 38 to 3.4Et 38
double 64 1.TE –308 to 1.TE + 308
Long double 80 3.4E –4932 to 1.1E +4932

Integer data types


Integer are whole no E a range of values supported by a perticatar machine. Geneally
integers occupy one word (16 – bit) of storage & since the word wize of machines vary
(typically 16 or 32 bit). The size of an integer that can be stored depends on the
computer. Generally we use 16 bit word length. The wize of the int. value is limited to
the range – 32768 to + 32767 ie. (2 15 to +2).
In order to provide some controle over the tange of the numbers 8 the storage
space ‘C’ gas 3 clases of integer storage, namy short – Int. 8 long Int. in both signed &
unsigned forms.

Floating data types


Floating points or real numbers are stored in 32 bits (on all 16 bits & 32 bits malhine), E
6 digits floating points fluffy points no one define in C by keyword float Glhen the acery
provided by float is not sufficient the type double can be used to define the numbers. A
double data type no uses 64 bits giving a floating point of 14 digits. To extend the
floating point we may use long double wihich use 80 bit.
Character type
A single character can be define as character data type (char) type data. Character are
unsaly stored in 8 bit of internal storage A qutifer signed 8 unsigned may be applied to
char.

Delcleration of Veravles
After designing suitable veriable name you must delclear them to the compler,
Dedlaration does now things
It tells the compiles what is the name of veiable.
Its specifies that , what type of date type veriable will hold.
The declaration of veriales must be done before they are word in the programme

Declaration of primary data types veriable


A veriable can be used to store a value of any data type the syntax of
declaing a veriable is as

Data type v1, v2, v3 ………….. Vn;


Eg.- int total;
Int total, menus, class;
Float light;
Double weight ;
Long int a;
Long double amount;
V1, v2, … Vn are the names of revibles are separated by comms (,) a declaration
statements must end E ;
Operator
An operator is a symbol that tells the computer to performs mythical or logical
operations. Operators are used in programme to manuculate data & verible. They
usually form a part of mathemical or logical e xpression.
C operator classifides in to noumbers of categories as follows
arithamatics operator .
relational operator.
Logical operartor
Assignment /shorthand operators
Inrement and decrement operator
Conditional operators
Bit wise operator
Special operators

arithmetic operator
‘C’ provides all the basic arithmetic operator like +, -, x, :- , etc. these can
operate on any built in data type allowed in ‘C’ the anargoperatior in effect multiplay its
apearand by – 1 therfore a number preceded by – signed changes its signed.
+ add n or anary plus.
- substtraction , unary minus
* multiplication
/ division
% modulo division
the modulo division producs the reminder of an intger division eg. Of aritmatic
operator are

a-b, a*b, a%b, -a/b, -a*b, a+b

Relational operator
We often compair two quantities & depending on their relation to take a qrfain decigion
eg. – we may compair age of two person or the prise of two items & so on. These
comparison can be done with the help of relationl operator & expressions such as ---
a<b. or 1<20
Containing a relational operator is turned as a relational expression the vale of
relational expession is either one or zero. Itnisn one if the specified relation is true
otherwise zero.
Eg. --- 10<20 --- true (1)
20<10 --- false (0)
‘C’ supports 6 relational operators as follows.

< Is less than


<= Is less than or equal to
> Is greater than
>= Is greater or equal to
== Is equal to
!= Not equal to

eg. -- 4.5 < = 10


4.5 < - 10 - false (0)
- 35 > = 0 - false
a+b==c+d
Relational expressions are used in decision statement such as if & while to
decide the action of running programme.

Logical Operators
In addition to relational operator ‘C’ has following 3 operators.

&& Logical and


I I 888 Logical or
! Logical not
The Logical operators & & (and) I I (or) are888
used when we want to test more than
or condition & make decision eg. --- a > b & & , x = = 10.
An expression of this kind which combining two or more relational extraction is
termed as Logical expression or a compound relational expression. Like a simple
relational expression a Logical expression also gives a value 1) or Zero, this is explain
with the help of the truth table as follows ----

OP–1

OP–2
Value of excretion

O P–1 & & O P2 P –1 I888


I OP2

Non Zero
Non Zero
1
1

Non Zero
0
0
1

0
Non Zero
0
1

0
0
0
0

Eg. – 1 if (age > 55 & & salary > 1000)


If (number < 0 ) 888
I I number > 100)
Assignment operator /short hand operator
These are used to assign the result of an expression of an expression to a variable. We
have seen the usual assignment operator =. C has a set of short hand assignment operators
of the form.
Syntax -- V. OP = exp

V – Variable, exp – expression &


Op – operator - a c binary automatic c operator
Op - is known as short hand assignment operator some of the community used short
hand assignment operator are illustrated as follows.

A=a+1 a+=1
A=a- 1 a- = 1
A = a * (n-1) a * = (n - 1)
A = a /(n+1) a / = (n + 1)
A=a%b a%=b
The use nof short hand operator has 3 advantages.
What appears on the C Left hand Side need not be repeated & therefore it becomes easier
to write.
The statement is more concise & easier to read.
The statement is more efficient eg. Value (5*J-2) = value (5*J-2) + data.
Using short hand operator value (5*J-2) + = data.

Increment & decrement operator


‘C’ has 2 very useful operator not generally found in other languages these are increment
& decrement operator i.e. + + & - - respectively.
The operator + + add 1 to operand, while - - subtract 1 from operands. Both are unary
operator & take the following form.

C type. H----
This is another system file like < stdio .h >, <math . h > This file contains the
character funn. Like.

Is alnum (c) - is c alphanumeric char


Is alpha (c) - is c alphabetic char
Is digit (c) - is c a digit
Is lower (c) - is c lower char
Is upper (c) - is c upper char
Is print (c) - is c print char
Is punct (c) - is c a punctuation make
Is space (c) - is c a blank space
To upper (c) - conrert a lower to upper
To lower (c) - convert a upper to lower.
It you want to use there all funn add a line in links seetion of prog. Like
# include <ctype .h >

Putchar ( )
This function is used for single character output it is a output function.
Syntax----
Variable = putchar ( ) ;
Switch statement -----
‘C’ has a built in multiway decision statements known as a switch.
The switch statements test the value of given variable (expression) against the cost of
case values & when the match is found a block of statement associated with case is
executed. The general form of switch statement is as follows ---.
The expression is an integer expression or characters.

Switch (expression)
{
Case value 1 :
Black 1 ;
Break ;
Case value 2 ;
Block 2 ;
Break ;
!!!!
Default
Default block ;
}
Statement x
When a stwich is executed the value of expression is succe ssively compaired
against values 0, value 1, value 2. If case is found whose matcher with the values of
expression then that block of statement that fallows the case are executed.

Break statement -----


Bread Statement at the end each block signals the end of particular case & cause
& exit from the switch statement. Transferring the control to the statement x.
The default is optional case. When prenent it will be executed if the value of
excretion demote E any case values. If not present no action takes place. If all matchs
fails & the control goes to the statement x.
GOTO Statement ---
‘C’ supports the goto statement to branch unconditionally from one point to
another in the programme. Although it may not be essential to use the goto statement in
lightly structured language C, these may be occacsion when the use of GOTO requiret
alable inorder to ideritify the place where the branch is to be made. A lable is any valid
veritable name (must be fallowed by colon(:)
syntax --- goto table :
label : statement

While Statement ---


(Decision malting & looping ) ---
The simplest of all looping str. In ‘C’ is the while statement.
The statement syntax of while statement
Is. –
While (test cont n)
{
Body of loop.
}
The while statement is an entry controlled loops statement. The test contn is true
then the body of loop is executed. After excoriation of the body the test cond n is one
again evaluated & if is true the body is executed on again. This prceres of repoated
exicution of the body cmtinuex unlit the test condn finaliy become false & the control is
transferred all of continuser E the statement immediate after the body of loop.
Eg. # include (stdio . h)
Main ( )
{
int I=0, sum=0 ;
while (I < = do)
{
I = I +2 ;
Slm = sum + I I
}
print f (“ % d ; sum);
}

The Do statement ----


On some occasions it might be nevermore to loop before the test perfrm such
situation can be handled E the help of do statement. The syntax of do statement is
Do
{
body of loop
}
while (test condn);
On eructing the do statement the prog. Procered to evaluate the body of loop first &
end of the loop the test condn in the while statement is evaluated of the condn is true the
prog. Continase to evaluate the body of loop once again. This procers continues as long
as condn is true. When the condn becomes false the loop will be terminated 2 the
control goes to the statement that appears immediately after the while enactment.

For Loop ----


For loop is another entry control loop that provider a more consiser loop control
str. The general format of the ofr loop is –

For (initialization; test- condn ; increment )


{
Body of loop
}

The exsiccation of the ‘for’ statement is as fallows.


initialization of the control versatile is done first, using assignment statement such as I=1,
& count = , The variables is count are known as loop control variables.
The value of the control variable is tested using the test condn the test condn is a relation
expression such as I<10 that determine when the loop will exit if the condn is true. The
body of the coop other wise the loop is terminated & the exicution continuer E the
statement. That immediate fallows the loop.
When the body of the loop is executed the control is transferred balle to the “for”
statement affer evaluating the last statement in the loop.
Alow the control variable is incremented using at assignment statement such as I = I + 1
& the new value of the controlled variable is agein tested to see whether it saties fies the
loop condn. If the of loop is again exicated. This proven continues till the value of
controlled verable fails to stats fint the test condn.

ARRAY
An “array” is a group of related data items that share a common away name salary
to represent a set of salaries of a employees. A particular sub- script in bracelet after the
array name eg. Salary [10] subscript
Represent the salary of the 10 the emplayce while the complcte set of values is
referred while the complete set of values values are called elements. Arrays can be of
any variable type.
Single dimensional or one-dimensional arrays -----
A list of items can be given variable name using only one subscript c such a
variable or one-dimensional array.
The subscript can begin E no O lie. Allowed eg. – it we want to reprenent a set of
five no say (35,42,20,57,90) by an array variable now. Then we may declea it as follows.
Int number [s];
And the comp reserres 5 storage location as shown below3
35

40

20

57

90

Number [0]
Number [1]
Number [2]
Number [3]
Number [4]

Two-dimensional arrays -----


So for we have disc the array variables that can store a list of values. There will
be situations where a table valurs have to be to read ‘C’ akkiyse ti defube sycg table
values have to be to red ‘C’ allous to define such table of items by using two dimensional
arrays. Two directional arrays are deloused as fallows.
Type variable name [row] [column]

Deldearing & initializing stewing variables –


A string variable is valid in ‘C’ & is always declased as an array 1/3
syntax is.—
Char stwingname [size];
The size determines the no of characters in the stewing name some egs are --
Chas city [10] ;
Chas name [30] ;
When the compiler assigins the character strings to a chas array. It automatically
suppliet a nul characterfore the size should be equall to the maxm no, of character strings
+ 1. character arrays. May be infialcde of when they are dedased. C pemists to chas
arrays to be initialized in citner off following two form.—

Static Char city [10] = “ New Delhi”


Static char city [0] = {‘N’ ; ‘E’, ‘W’, ‘O’, ‘e’, ‘x’, ‘w’, ‘10’ }
Static char city [10]. “New delhi” ;

String handling funns


The ‘C’ library supports the no of string handing funn that can be used to carry
out many of the string manuplicaticrs .
Note :- whenever you use the string handing funn lst you have to add the
fallowing line in link seetion ---
# include <string . h>
The fallowing are some imp string
1) strcat ( )--
The funn joines two string together its formate is – strcat (string 1, string 2) ;
String 1 & string 2 are Char array when the funn strcat executed, string 2 is
appended to string 1. It does so by removing null character at the end string case &
placing string 2 there we must make such that the size of string 1 (to which string 2 is
appended) large enough to accommodate the string.
2) strcmp ( ) --
This is the funn which compare string to find out wherer they are same or diff. Its
format is –
Strcmp (string 1, string 2) ;
The strings are to compared char by char until ther is mismatch of end one of the
string is reached. Which ever occures first. It two strings identical strcmp returnt the
value O if they are not it return the number diif betn ASCII value of non matching
character.
3) strlen ( ) --
This funn counts the char. Present in a string. Its syntax is –
N = Strlen ( string) ;
N is an int variable that receives the value of the laugh of the string.
4) strcpy ( ) ---
This funn copies the contains of one string to another. It assigns contains.
Syntax :- strcpy (string 1, string 2);
String 2 to string one.

User define funn ---


‘C’ funn can be classified into this categories. 1) Library funn 2) user define
funn . Main ( ) is an eg. of user define funn.
The main distinction betn these two categories is that library funn are not required
to be written. By us where has user define funn has to be developed by the user at the
time of a writting a prog.
Every ‘C’ prog. Must have a main funn to indicted were the prog. Has to begin its
exicution. While if is possible to code any programme using only main function but it
leads problem.
If a prog. is divided into functional parts part & then each pat may be
independently coded & later combined into single unit. There sub prog. called funn are
much easier to understand, debug & test. [The from of c funn ]
Funn name (argument list)
Argument declaring,
{
Local variables declaration ;
excitable statement ;
excitable statement 2
retun (oxprention);
}

Category of funn ----


1) function with no argument & or return value .
2) function with argument & no return value.
3) function with argument & return value.

1) funn with no argument & no return value.


When a funn has no argument it doesn’t receive any data from the calling funn. When it
doesn’t return value.
In effect there is no data transform between calling and called functions

Fun n with Arguments E returns value ----


The funn receives data from the calling funn through the arguments. But donut
sent back any value. Rather it displays the result of calculations at the terminal. However
we may not always wish to have a results of a funn displayed we may use it in the calling
funn for ferther processing. More over to assure the ligh degree of portability betn
programmes of a funn should generally be coded without in volving any I/o operations.
Eg – diff progs may required diff. Output for displaying result.
Recursion ---
In C it is possible for the funn to call themselves. A funn called recursive if a
statement within a body of a funncalles the same funn, recession is thus the process of
defining something internal of itself.

Storage classes -----


There are 4 storage classes auto, static, Extern & Register.
Auto –
Automatic variables are declare inside a funn in which they are used. They are created
when the funn is called & destroyed when the funn is executed.

* Static (variable) -----


As the name suggest the value of a variable persist until the end of the prog. A
static variable can be declare using the key word static like – static int x ; static float y ;
Eg. – illustration static variables.

POINTERS
Pointers are the important feature of ‘C’ language. They are the powerful tools.
These are no of reasons for using the pointers.
Pointers enables us to access the veriable that is define outside the funn.
Pointers are more efficient in handling data tables (row & colum data rearranges).
Pointer reduces the length to & complicity of a programme.
They increase the execution speed.
The use of pointer array to char strings result in saving a data storage space in memory.
Eg. – int qty = 179
qty – variable name
179 – value.
5000 – address.
As you know comp. User their memory for storing instruction of a program. As
well as the value of a variable that are associated with it. The comp. Memory is a
sequential collection of storage cell. Commonly knows as byte & its has a number called
adderss. The add. Are the numbers consecutively starting from O the last add depends on
the memory size. The camp syst having 64 m3 memmory will have last adders 65535.
when even we deelear a veiable. The systems allocates some where in the memory and
appropriate location to whole the values viable since very byte has unique address.
Eg. – int aty = 179
This statement instruet the system. To find location for int. variable

Assume that system has chosen the add. Location five thousand for qty during the
execution of program the system. Always associate the name qty with the address five
thousand we may have acces the value 179 by using eitmer mane aly of the add 5000
since the memory address are simply number they can be assign to some variable which
can be stored in memory like any other viable. Such variable that hdd memory address.
Are called pointers.
A pointer is there for nothing but a veriable that contains an add. Which is
location of another variable in memory remember since a pointer is a variable its value is
also stored in the memory in another location suppose 1 asign the add. Of quantity &
veriable p . the link betn variable & and aty I s snown in following fig.

Variables value add


qty 179 5000
P 5000 5048

The address of p is 5048 since the value of variable quantity. We may access the,
value of qty by using the value of p and therefore which say that the variable p point to
the variable qty than p gets name pointer.
*Assessing the value of variables –
The location of the variable in the memory is syst dependant & there fore the add
of variable is not known to us immediathy. This can be done with the help of operator
address in C. the operator & immediately preceding a variable retan the the add. Of the
variable associated with it
Eg. – P = & city
P = 5000

Accessing the variables through its pointer :-


Once the pointer has been assign the add. Of variable the question remains that
how to access the value of variable using the pointers. This is done by another unary
operator - * (astric) usualey known an the the indication operator. Conrder the fowwing
statement –

Int qty, n, * P ;
Qty = 179
N = * pi
The first line decleare qty and. An as int variable and P is a pointer variable.
Pointing to as int the second time assign the values 179 to qty. At the third line
assig1
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616

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