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

Give brief explanation about the keyboards, Give brief explanation about th...

Give brief explanation about the keyboards Keyboards are generally not offered as the number of options is limited and owners of the system do not want customers keying in info

What is cache coherency, Cache coherence refers to the integrity of data st...

Cache coherence refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence. When clients in a system, mainly

How the simulation is done, How the simulation is done Data is entered ...

How the simulation is done Data is entered into the computer and simulation is run. The below scenarios may be tried out: -  Timing of lights varied to see how traffic flow

Explain the concepts and definitions of e-commerce, The Internet has emerge...

The Internet has emerged as a major worldwide distribution channel for goods, managerial, services, and professional jobs. It has impacted market economics and industry structure,

How do you find out if a linked-list has an end, By 2 pointers you can find...

By 2 pointers you can find it. One of them goes 2 nodes each time. The second one goes at 1 node each time. If there is a cycle, the one that goes 2 nodes every time will eventuall

Explain tri-state logic inverter, Explain Tri-state logic inverter with the...

Explain Tri-state logic inverter with the help of a circuit diagram. Give its Truth Table. Ans: Tri-state Logic Inverter: The functional diagram of Tri-state Logic Inve

Define windows authentication, Windows Authentication This provider uti...

Windows Authentication This provider utilizes the authentication capabilities of IIS. After IIS completes its authentication, ASP.NET uses the authenticated identity's token to

Elaborate the various steps in performing a mail merge, COMPUTER FUNDAMENTA...

COMPUTER FUNDAMENTALS 1. Elaborate the various steps in performing a Mail Merge. Perform one mail merge operation for sending invitation for a conference which is being conduc

Reading every record , You have a file having sporting goods that are sold ...

You have a file having sporting goods that are sold online. Every item record contains the item id, item name, item description, item category, item price, and the units in stock.

Cohesion, Identify the type of cohesion in the following statements: 1. ...

Identify the type of cohesion in the following statements: 1. Compute average daily temperatures at various sites 2. Initialize sums and open files 3. Create new temperature rec

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