by Dinesh Thakur
Category: Type And Variables

A variable is an object whose value may change during execution of a program. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Variable names are case sensitive. Others are constants whose values cannot be changed during the execution of the program. However, their values have to be declared. In a program a variable may be declared as below.

by Dinesh Thakur
Category: Type And Variables

If you might need large values (above 32,767 or below -32,767), use long. Otherwise, if space is very important (i.e. if there are large arrays or many structures), use short. Otherwise, use int. If well-defined overflow characteristics are important and negative values are not, or if you want to steer clear of sign-extension problems when manipulating bits or bytes, use one of the corresponding unsigned types. (Beware when mixing signed and unsigned values in expressions, though.) Although character types (especially unsigned char) can be used as "tiny'' integers, doing so is sometimes more trouble than it's worth, due to unpredictable sign extension and increased code size.

by Dinesh Thakur
Category: Type And Variables

An object is recognized by the computer by either its identifier or name. The object may be a variable of basic type or a function, a structure, or a union. The macro names and macro variables do not figure in the scope because macros are replaced by the preprocessor token sequences before the semantic phase of program translation. An identifier may also represent different objects in different scopes.

by Dinesh Thakur
Category: Type And Variables

Both variables and the constants may have different types of values. In C language, different forms of data are categorized into a few abstract **data types. **For example, suppose you are asked to keep the record of the number of passengers in a bus. A variable say *N, *which is used to denote this number, will have value in whole numbers because the number of passengers cannot be a fractional number. Similarly, for number of students in a class, number of apples in a basket, number of pages in a book, or number of houses in a colony, etc., the values must be in whole numbers. Whole numbers form a category called **integers. **In C language, this *type *is coded as **int, **a short form for integer.

by Dinesh Thakur
Category: Type And Variables

A storage class specifies how the variables are used in the program.

by Dinesh Thakur
Category: Type And Variables

There are many different types of data values that are implicitly declared as constants in C. The value of a constant cannot be changed during execution of the program, neither by the programmer nor by the computer. The character 'A' is a constant having numerical value equal to 65 in decimal number system.

by Dinesh Thakur
Category: Type And Variables

Enumeration is a data type*, *which is coded as **enum, **may be used to define user's own data type and define values that the variable can take. The enumeration type is an integral data type. This can help in making program more readable. enum definition is similar to that of a structure. Its syntax is as follows:

by Dinesh Thakur
Category: Operator

The const qualifier tells the compiler that the variable's value should not be changed once it has been initialized. If we declare a const variable as

by Dinesh Thakur
Category: Operator

Boolean operators AND, OR, and NOT are used to manipulate logical statements. Boolean operators are the core operators used in digital control systems as well as computer systems. AND and OR are binary operators, while NOT is a unary operator. Let *A *and *B *be two logical statements or variables representing logical statements. If a logical statement is *true *it may be assigned the value 1, and if a logical statement is *false *it may be assigned the value 0. Table gives details of the three operators AND, OR, and NOT.

by Dinesh Thakur
Category: Operator

Arithmetic operators may be combined with the assignment operator to obtain composite assignment operators. An arithmetic operator is written first followed by the assignment operator but not vice versa. **In all the composite operators there should not be any blank space between the symbols. **For instance, in+= if we give space between+ and= (suchas+ =),it may result in an error.

by Dinesh Thakur
Category: Operator

We have used the assignment operator (=), which is often called *equal to *in algebra. On the left of this operator we write the name of variable or l-value to which a value is to be assigned, and on right side we write the value to be assigned to it or r-value. The l-value is the memory segment in which the r-value is stored. Let A, B, and ch is the names of three variables declared as given below.

by Dinesh Thakur
Category: Operator

There are five arithmetic operators, +, -, *, *I, *and %, which respectively represent the processes of addition, subtraction, multiplication, division, and modulus. The modulus operator (%) gives the remainder when one integer is divided by another integer. All of the five operators have been described with examples of codes in Table.

by Dinesh Thakur
Category: Operator

The sizeof operator is another method to determine the storage requirements of any data type of variable during the execution of a program. For example, we can use the expression.

by Dinesh Thakur
Category: Operator

All the objects that are stored in a computer are ultimately converted into binary numbers which are sequences of 0s and 1s. Each digit in a binary number is stored on one bit of the computer memory. A *bit *is defined as the smallest unit of memory in a computer. In fact, computer manipulates a number by manipulating the bits on which the number is stored. In control systems also we often need to use operators to manipulate bits.

by Dinesh Thakur
Category: Operator

The C language provides three **logical operators **that can be used to join relational and equality expressions and form complex **Boolean expressions, **i. e., expressions with operands having *true *or *false *values. These operators include *logical AND (&&), logical **OR *(||) and *logical **NOT *(!). They are summarized in Table.

by Dinesh Thakur
Category: Operator

The C language provides four relational and two equality operators for comparing the values of expressions. The **relational operators **are *less than (*<), *greater than *(>), *less than or equal to (*<=) and *greater than or equal to *(>= ). The **equality operators **are *equal to *(==) and *not equal to ( ! *=). These operators are binary infix operators, i. e., they are used in the form *a op **b, *where *a *and bare operands (constants, variables or expressions) and *op *is a relational or an equality operator. Table summarizes these operators.

by Dinesh Thakur
Category: Operator

The **conditional expression operator **(? :) is the only ternary operator in the C language. The conditional selection operator(? :) is more convenient to use than if-else provided there are only two options to choose from. It takes three operands and is used to evaluate one of the two alternative expressions depending on the outcome of a test expression as shown below.

by Dinesh Thakur
Category: Operator

**Arithmetic operators **are used to perform arithmetic operations on arithmetic operands, i. e., operands of integral as well as floating type. Recall that an integral type includes all forms of char and int types, whereas the floating-point types include the float, double and long double types. These operations include addition (+), subtraction (- ), multiplication (*), division (!), modulo arithmetic (%), increment (++), decrement (-- ), unary plus (+) and unary minus (- ). They can be grouped into three categories: *unary *operators, *multiplicative *operators and *additive *operators. The arithmetic operators are summarized in Table.

by Dinesh Thakur
Category: Operator

The operator precedence and associativity rules specify the order in which operators in an expression are bound to the operands. These rules enable us to interpret the meaning of an expression in an unambiguous manner.

by Dinesh Thakur
Category: Operator

**Operators **are used to connect **operands, **i. e., constants and variables, to form **expressions.**

About Dinesh Thakur

Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Basic Courses

Advance Courses