Explain difference between a constant and variable, Computer Engineering

Assignment Help:

What is the difference between a constant and variable? Explain with example.

 A C constant is usually just the written version of a number. For example 1, 0, 5.73, 12.5e9. We can specify our constants in octal or hexadecimal, or force them to be treated as long integers.

  • Octal constants are written with a leading zero - 015.
  • Hexadecimal constants are written with a leading 0x - 0x1ae.
  • Long constants are written with a trailing L - 890L.

Character constants are usually just the character enclosed in single quotes; 'a', 'b', 'c'. Some characters can't be represented in this way, so we use a 2 character sequence.

'\n'         -           newline

'\t'          -           tab

'\\'          -           backslash

'\''          -           Single Quote

'\0'          -           null ( used automatically to terminate character strings)

 

In C, a variable must be declared before it can be used. Variables can be declared at the start of any block of code, but most are found at the start of each function. Most local variables are created when the function is called, and are destroyed on return from that function.

A declaration begins with the type, followed by the name of one or more variables. For example,

 

int high, low, results[20];

 


Related Discussions:- Explain difference between a constant and variable

Recursion, Ask qurecurrion for short noteestion

Ask qurecurrion for short noteestion

Write miss policy - cache memories, WRITE MISS POLICY:   Write allo...

WRITE MISS POLICY:   Write allocate   fetch on write   fetch entire block, then write word into block   allocate a new block on each writ   allocate block, but

Types of messages, Q. Types of messages? The messages can be of many ty...

Q. Types of messages? The messages can be of many types.  A specific field of all messages may be reserved to signify message type.  The message passing primitives are like thi

Explain the meaning of connect socket primitive, Explain the meaning of ...

Explain the meaning of CONNECT socket primitive. The connect Primitive: Clients utilize procedure connect to establish connection with an exact server. The form is

Differentiate b/w program translation and interpretation, Differentiate bet...

Differentiate between program translation and program interpretation. The program translation model makes the execution gap through translating a program written in a program

Fundamental difference between smart card and e-cash, What is the fundament...

What is the fundamental difference between the transactions made using Smart Card and E-cash? Smart Card and E-Cash: E-cash storable smart cards can dispense and store ca

What do you mean by keyboard touch, Q. What do you mean by Keyboard Touch? ...

Q. What do you mean by Keyboard Touch? When employing a keyboard the most important factor is the feel of keyboard it implies that how typing feels on that specific keyboard.

How will you prepare problem statement, How will you prepare problem statem...

How will you prepare problem statement? Problem statement should state what is to be completed and not how it is to be executed. It should be a statement of requirements not a

Optimum solution based on constraint problems, Optimum solution based on co...

Optimum solution based on constraint problems: Whether depending on what solver you are using so there constraints are often expressed as relationships between variables as e.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd