An introductory C programming document covering variable naming rules, basic data types, variable definition, declaration, initialization, and classifications. It explains lvalues and rvalues, then presents arithmetic, relational, logical, bitwise, assignment, and miscellaneous operators with examples and tables. The document concludes with operator precedence and associativity.
Free preview text
The first 5 pages, shown as text so search engines and readers can find this document.
Page 1
Use of the Variables in C
Variables are the storage areas in a code that the program can easily manipulate. Every variable
in C language has some specific type- that determines the layout and the size of the memory of
the variable, the range of values that the memory can hold, and the set of operations that one
can perform on that variable.
The name of a variable can be a composition of digits, letters, and also underscore characters.
The name of the character must begin with either an underscore or a letter. In the case of C, the
lowercase and uppercase letters are distinct. It is because C is case -sensitive in nature. Let us
look at some more ways in which we name a variable.
Rules for Naming a Variable in C
We give a variable a meaningful name when we create it. Here are the rules that we must follow
when naming it:
1. The name of the variable must not begin with a digit.
2. A variable name can consist of digits, alphabets, and even special symbols such as an
underscore ( _ ).
3. A variable name must not have any keywords, for instance, float, int, etc.
4. There must be no spaces or blanks in the variable name.
5. The C language treats lowercase and uppercase very differently, as it is case sensitive.
Usually, we keep the name of the variable in the lower case.
Let us look at some of the examples,
int var1; // it is correct
int 1var; // it is incorrect – the name of the variable should not start using a number
int my_var1; // it is correct
int my$var // it is incorrect – no special characters should be in the name of the variable
char else; // there must be no keywords in the name of the variable
int my var; // it is incorrect – there must be no spaces in the name of the variable
int COUNT; // it is a new variable
int Count; // it is a new variable
int count; // it is a valid variable name
Data Type of the Variable
We must assign a data type to all the variables that are present in the C language. These define
the type of data that we can store in any variable. If we do not provide the variable with a data
type, the C compiler will ultimately generate a syntax error or a compile -time error.
The data Types present in the C language are float, int, double, char, long int, short int, etc.,
along with other modifiers.
Types of Primary/ Primitive Data Types in C Language
Page 2
The variables can be of the following basic types, based on the name and the type of the
variable:
Type of
Variable
Name Description Uses
char Character It is a type of integer. It is
typically one byte (single
octet).
We use them in the form of single alphabets,
such as X, r, B, f, k, etc., or for the ASCII
character sets.
int Integer It is the most natural size of
an integer used in the
machine.
We use this for storing the whole numbers,
such as 4, 300, 8000, etc.
float Floating-
Point
It is a floating-point value
that is single precision.
We use these for indicating the real number
values or decimal points, such as 20.8, 18.56,
etc.
double Double It is a floating-point value
that is double precision.
These are very large-sized numeric values that
aren’t really allowed in any data type that is a
floating-point or an integer.
void Void It represents that there is an
absence of type.
We use it to represent the absence of value.
Thus, the use of this data type is to define
various functions.
Let us look at a few examples,
// int type variable in C
int marks = 45;
// char type variable in C
char status = „G‟;
// double type variable in C
double long = 28.338612;
// float type variable in C
float percentage = 82.5;
If we try to assign a variable with an incorrect value of datatype, then the compiler will (most
probably) generate an error- the compile-time error. Or else, the compiler will convert this value
automatically into the intended datatype of the available variable.
Let us look at an example,
#include <stdio.h>
int main() {
// assignment of the incorrect value to the variable
int a = 20.397;
printf(“Value is %d”, a);
Page 3
return 0;
}
The output generated here will be:
20
As you can already look at this output- the compiler of C will remove the part that is present after
the decimal. It is because the data types are capable of storing only the whole numbers.
We Cannot Change The Data Type
Once a user defines a given variable with any data type, then they will not be able to change the
data type of that given variable in any case.
Let us look at an example,
// the int variable in C
int marks = 20;
float marks; // it generates an error
Variable Definition in C
The variable definition in C language tells the compiler about how much storage it should be
creating for the given variable and where it should create the storage. Basically, the variable
definition helps in specifying the data type. It contains a list of one variable or multiple ones as
follows:
type variable_list;
In the given syntax, type must be a valid data type of C that includes w_char, char, float, int, bool,
double, or any object that is user-defined. The variable_list, on the other hand, may contain one
or more names of identifiers that are separated by commas. Here we have sho wn some of the
valid declarations:
char c, ch;
int p, q, r;
double d;
float f, salary;
Here, the line int p, q, r; defines as well as declares the variables p, q, and r. It instructs the
compiler to create three variables- named p, q, and r- of the type int.
We can initialize the variables in their declaration (assigned an initial value). The initializer of a
variable may contain an equal sign- that gets followed by a constant expression. It goes like this:
type variable_name = value;
A few examples are −
extern int p = 3, q = 5; // for the declaration of p and q.
int p = 3, q = 5; // for the definition and initialization of p and q.
byte x = 22; // for the definition and initialization of x.
char a = „a‟; // the variable x contains the value „a‟.
Page 4
In case of definition without the initializer: The variables with a static duration of storage are
initialized implicitly with NULL (here, all bytes have a 0 value), while the initial values of all the
other variables are not defined.
Declaration of Variable in C
Declaring a variable provides the compiler with an assurance that there is a variable that exists
with that very given name. This way, the compiler will get a signal to proceed with the further
compilation without needing the complete details regarding that variable.
The variable definition only has a meaning of its own during the time of compilation. The compiler
would require an actual variable definition during the time of program linking.
The declaration of variables is useful when we use multiple numbers of files and we define the
variables in one of the files that might be available during the time of program linking. We use
the extern keyword for declaring a variable at any given place. Though we can declare one
variable various times in a C program, we can only define it once in a function, a file, or any block
of code.
Example
Let us look at the given example where we have declared the variable at the top and initialized
and defined them inside the main function:
#include <stdio.h>
// Declaration of Variable
extern int p, q;
extern int c;
extern float f;
int main () {
/* variable definition: */
int p, q;
int r;
float i;
/* actual initialization */
p = 10;
q = 20;
r = p + q;
printf(“the value of r : %d \n”, r);
i = 70.0/3.0;
printf(“the value of i : %f \n”, i);
return 0;
}
The compilation and execution of the code mentioned above will produce the result as follows:
the value of r : 30
Page 5
the value of i : 23.333334
Classification of Variables in C
The variables can be of the following basic types, based on the name and the type of the
variable:
Global Variable : A variable that gets declared outside a block or a function is known as
a global variable. Any function in a program is capable of changing the value of a global
variable. It means that the global variable will be available to all the functions in the code.
Because the global variable in c is available to all the functions, we have to declare it at
the beginning of a block. Explore, Global Variable in C to know more.
Example,
int value=30; // a global variable
void function1(){
int a=20; // a local variable
}
Local Variable: A local variable is a type of variable that we declare inside a block or a
function, unlike the global variable. Thus, we also have to declare a local variable in c at
the beginning of a given block.
Example,
void function1(){
int x=10; // a local variable
}
A user also has to initialize this local variable in a code before we use it in the program.
Automatic Variable: Every variable that gets declared inside a block (in the C language)
is by default automatic in nature. One can declare any given automatic variable explicitly
using the keyword auto.
Example,
void main(){
int a=80; // a local variable (it is also automatic variable)
auto int b=50; // an automatic variable
}
Static Variable: The static variable in c is a variable that a user declares using
the static keyword. This variable retains the given value between various function calls.
Example, void function1(){
int a=10; // A local variable
static int b=10; // A static variable
a=a+1;
b=b+1;
printf(“%d,%d”,a,b);
}
If we call this given function multiple times, then the local variable will print this very same
value for every function call. For example, 11, 11, 11, and so on after this. The static
variable, on the other hand, will print the value that is incremented in each and every
function call. For example, 11, 12, 13, and so on.
External Variable: A user will be capable of sharing a variable in multiple numbers of
source files in C if they use an external variable. If we want to declare an external
variable, then we need to use the keyword extern.
Syntax, extern int a=10;// external variable (also a global variable)
Use of the Variables in C: summary, contents and background
This guide helps you understand the scope of Use of the Variables in C before or alongside reading the original document. It is based on the catalogue record, credited creator, source, classification and topics shown on this page. It does not replace the original work and does not invent claims about passages that Doxxly cannot verify.
Summary and overview
Use of the Variables in C is a 12-page documentcredited to Zora C. Cressley. An introductory C programming document covering variable naming rules, basic data types, variable definition, declaration, initialization, and classifications. It explains lvalues and rvalues, then presents arithmetic, relational, logical, bitwise, assignment, and miscellaneous operators with examples and tables. The document concludes with operator precedence and associativity. It appears in the Education & Learning collection, which groups it with other material that readers may use for comparison and further study.
The item can be approached in several ways. A reader looking for a quick orientation can begin with the free five-page preview, inspect the page structure and use the metadata to judge relevance. Someone undertaking deeper research can work through the complete file, search its indexed text, record useful page references and compare its treatment of C programming, Variables, Data types, Declarations, Initialization, Operators, Operator precedence with the related resources linked below.
Rather than reducing the work to a single claim, this page treats it as a source that should be read in context. The title, creator, publication source, licence and format all help explain what kind of evidence it may offer. Readers should distinguish the original author's statements from Doxxly's catalogue description, and should cite the original edition when using the material in academic, professional or published work.
Key topics and reader takeaways
The catalogue connects this document with C programming, Variables, Data types, Declarations, Initialization, Operators, Operator precedence. These terms offer practical entry points rather than a substitute for close reading. Start by identifying the definitions, examples, arguments, tables or visual explanations attached to each topic. Then note where the creator draws connections, makes distinctions or moves from background material to a conclusion, recommendation, calculation or narrative development.
A useful reading method is to separate description from interpretation. First record what the item actually presents: names, headings, figures, formulas, quotations or stated propositions. Next consider why those details matter within the whole work. Finally compare them with another source from the same subject area. This process helps turn a long digital file into evidence that can be evaluated rather than merely skimmed.
Table of contents and reading guide
The following is an editorial content guide based on the verified catalogue topics. It is not represented as the original author's formal table of contents. Use it to organise notes while moving through the 12 pages in the player.
Part 1
C programming
Use this section of the reading guide to identify how C programming appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 2
Variables
Use this section of the reading guide to identify how Variables appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 3
Data types
Use this section of the reading guide to identify how Data types appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 4
Declarations
Use this section of the reading guide to identify how Declarations appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 5
Initialization
Use this section of the reading guide to identify how Initialization appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 6
Operators
Use this section of the reading guide to identify how Operators appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
Part 7
Operator precedence
Use this section of the reading guide to identify how Operator precedence appears in Use of the Variables in C, note important terms, and connect the subject to the wider purpose of the work.
When a heading in the original differs from this guide, follow the original heading in your citation. Page numbers can also vary between editions. Doxxly's direct page field is useful for navigation, but formal references should include the title, creator, source and edition details available in the file itself.
About Zora C. Cressley
Doxxly credits Zora C. Cressley as the author or creator of Use of the Variables in C. This page does not add an unverified biography, job title or institutional affiliation. The attribution is preserved so readers can distinguish the creator from the hosting library and follow the original record when an external author link is available.
Author context matters because a work reflects a particular purpose, audience and point of view. Before relying on the material, consider what the creator set out to explain, when the source was produced and whether later research or revised guidance should also be consulted. For literature and philosophy, compare translations and editions; for technical material, check whether a newer version has superseded the one shown here.
About the source organisation
The recorded source for this item is kanyashreecollege.ac.in. Doxxly provides access and discovery tools but does not claim to be the original publisher unless explicitly stated. Source links, creator attribution and the recorded Publicly available file collected for editorial review licence are displayed to help readers assess provenance and permitted use.
Provenance is especially important for reports, standards, presentations and working spreadsheets. Check the original source for amendments, supporting files and current policy. A trustworthy research workflow keeps the source URL with any notes or downloaded copy, verifies important figures against the original, and avoids treating an archived document as automatically current.
Begin with the title and opening pages, then use the guide above to decide whether to read sequentially or move to a particular topic. The Doxxly player provides previous and next navigation, a direct page field, zoom steps, fit-to-width and fit-to-page modes, rotation and fullscreen. These controls are useful when a page contains small type, a wide table, an image, a scanned layout or a dense sequence of notes.
The first five pages are open to every visitor. A plan unlocks the complete item and full-document search. Search is best used for distinctive names, technical terms or short phrases; broad words can produce too many possible contexts. When you find a useful passage, read the surrounding pages so that a sentence, chart or formula is not separated from its explanation.
If downloading is enabled, members can obtain the original PDF file. Keep the original format when formulas, slide sequencing, pagination or layout carries meaning. Respect the Publicly available file collected for editorial review terms displayed on this page, and use the rights-report link if you believe the attribution or availability needs review.
Research questions to consider
As you read Use of the Variables in C, ask which audience the creator addresses, what problem or idea organises the work, what evidence is presented, and which assumptions remain unstated. Note whether important terms are defined consistently and whether examples represent a broader pattern or a narrow case. For quantitative material, record units, time periods, formulas and data sources. For interpretive material, separate the creator's language from your own summary.
A second set of questions concerns relevance today. Which parts remain durable, which depend on their historical or institutional setting, and what would need confirmation from a newer source? Following the tags and the Education & Learning collection can reveal useful comparisons. Agreement between sources can strengthen confidence, while disagreement can point to changing definitions, methods, evidence or priorities.
Finally, decide what you need from the item: background knowledge, a quotation, a worked example, a model, a visual explanation or a starting bibliography. That purpose should guide the depth of reading and the notes you keep. Doxxly helps locate and navigate the source; careful interpretation remains the reader's responsibility.