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

Direct isp service through leased line, The most expensive method of access...

The most expensive method of accessing Internet is to use leased lines which connect directly to the ISP. This will increase access rate to anywhere between 64 K and 1.5 Mbps, rely

What does realized mean, Realized mean that the component has been painted ...

Realized mean that the component has been painted on screen or that is prepared to be painted. Realization can take place by invoking any of these methods. setVisible(true), show()

Example on multi-statement forall construct, Q. Example on Multi-statement ...

Q. Example on Multi-statement FORALL construct? The subsequent statements set every element of matrix X to sum of its indices.  FORALL (i=1:m, j=1:n)      X(i,j) = i+j an

What is the purpose of linq providers in linq, LINQ Providers are a set of ...

LINQ Providers are a set of classes that takes a LINQ query and dynamically produces a method that implements an equivalent query against an exact data source.

Explain difference between macro call and macro expansion, Explain differen...

Explain difference between macro call and macro expansion. Macro expansion: While a macro name is used along with a set of actual parameters this is replaced through a code g

Advantages of random scan display, Advantages of random scan display ...

Advantages of random scan display Early computer displays: basically an oscilloscope. Control X, Y with vertical/horizontal plate voltage. Often used intensity as

Operating system., what is the minimum number of page faults for an optimal...

what is the minimum number of page faults for an optimal page replacement strategy?

Processor-memory interconnection network (pmin), Processor-Memory Interconn...

Processor-Memory Interconnection Network (PMIN) This is a switch that joined various processors to different memory modules. Connecting every processor to each memory module in

Strategy used for the project design, This project is divided to two parts ...

This project is divided to two parts (hardware and software) each with is subtask and consideration was given in all areas in order to meet the target specification. Solutions are

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