declare

Identifiers & Variables in C Programming



Sharing buttons:

tech duo

identify errs and variables in C

programming

identifier Zin see

in see the names of variables functions

labels and various other user-defined

objects are called identifiers z'

these identifiers z' can vary from one

to several characters

the first character must be a letter or

an underscore and subsequent characters

must be either letters digits or

underscores

here are some correct and incorrect

identifier names

[Music]

identifier upper and lower case are

treated as distinct hence count with all

lowercase count with capital C and count

with all uppercase are three separate

identifiers

an identifier cannot be the same as AC

keyword and should not have the same

name as functions that are in the c

library

variables in C

a variable is a named location in memory

that is used to hold a value that may be

modified by the program

all variables must be declared before

they can be used

the general form of a

raishin is type variable list here type

must be a valid data type and variable

list may consist of one or more

identifier names separated by commas

rations

[Music]

types of variables

variables will be declared in three

basic places in

functions in the

definition of function parameters and

outside of all functions

these are local variables formal

parameters and global variables

local variables

variables that are declared inside a

function are called local variables

local variables may be referenced only

by statements that are inside the block

in which the variables are declared

in other words local variables are not

known outside their own code block

most common codeblock in which local

variables are declared is the function

for example consider the following

function

here the integer variable X is declared

in function func 1

formal parameter

if a function is to use arguments it

declare variables that will accept the

values of the arguments

these variables are called the formal

parameters of the function

they behave like any other local

variables inside the function

as shown in the following program

fragment their declarations occur after

the function name and inside parentheses

[Music]

here a and B are declared as formal

parameters for the function func 1

global variables

unlike local variables global variables

are known throughout the program and may

be used by any piece of code

you create global variables by declaring

them outside of any function

any expression may access them

regardless of what block of code that

expression is in

for example

[Music]

here variable count is declared outside

the function main but still can be

accessed by the function

variable initializations

you can give variables of value as you

declare them by placing an equal sign

and a value after the variable name

the general form of initialization is

type variable name equal to value

some examples are thanks for watching

please like share and subscribe

[Music]