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

Example of assembly program, Sample Program In this program we only dis...

Sample Program In this program we only display: Line                             Offset Numbers                          -----------------Source Code-----------------

Explain about algebraic simplification, Q. Explain about Algebraic Simplifi...

Q. Explain about Algebraic Simplification? We have already determined algebraic simplification of logic circuit. An algebraic expression can exist in SOP or POS forms.  Let's i

Fundamental types of flash memory, Q. Fundamental types of flash memory? ...

Q. Fundamental types of flash memory? Code Storage Flash which is made by Intel, AMD, Atmel. It stores programming algorithms and it is largely found in cell phones. Data

Enumerate the history of computers, Enumerate the History of computers ...

Enumerate the History of computers Basic information about technological development trends in computer in past and its projections in future. If you want to know about compute

What is hashing, What is Hashing? Hashing: Hashing gives the direct acc...

What is Hashing? Hashing: Hashing gives the direct access of record from the file no matter where the record is in the file. This is possible with the help of a hashing functio

Example of time division multiplexing, Two computers using TDM take up turn...

Two computers using TDM take up turns to send 100-bytes packet over a shared channel that operates at 64000 bits per second. The hardware takes 100 microseconds after one computer

Hashing, what is hashing in database management system?

what is hashing in database management system?

Process of breadth first search, Process of Breadth first search: It's...

Process of Breadth first search: It's very useful to think of this search as the evolution of the given tree, and how each string of letters of word is found via the search in

What is unique port number, Q. What is Unique port number? A port is an...

Q. What is Unique port number? A port is an extra 16-bit number which uniquely identifies particular service on any given machine on Internet. Port numbers are 16 bit wide, con

Split bus operation - universal serial bus , Split Bus Operation - universa...

Split Bus Operation - universal serial bus :   USB 2.0 devices utilize a special protocol in the reset time that is called "chirping", to negotiate the high speed mode

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