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

Explain what are user controls, Briefly explain what user controls are and ...

Briefly explain what user controls are and what server controls are and the differences between the two.   An ASP.NET control (sometimes known as a server control) is a server-

Engineering maths, calculate dy/dx if y=[x-cos(1/cos(xe/2x))]/x

calculate dy/dx if y=[x-cos(1/cos(xe/2x))]/x

Engineering and scientific software, Engineering and Scientific Software ...

Engineering and Scientific Software Engineering  and  Scientific  software  has  been  characterized  with "number crunching" algorithms. Application starts from astronomy t

Contraposition, Contraposition : The contraposition equivalence is as ...

Contraposition : The contraposition equivalence is as follows:  So it may seem a small strange at first, this means that it appears which we have said nothing in the f

Explain parallelism conditions, Parallelism Conditions As discussed ear...

Parallelism Conditions As discussed earlier, parallel computing needs the segments to be executed in parallel should be independent of each other. So before executing paralleli

Virtual manufacturing system, Virtual Manufacturing System Virtual manu...

Virtual Manufacturing System Virtual manufacturing system or VMS is a synthetic, integrated manufacturing environment, developed by using information technology tools, exercise

The statement vline is used to insert vertical lines, Like ULINE the statem...

Like ULINE the statement VLINE is used to insert vertical lines. No , Vline is not used to insert vertical lines.

What is page frame, What is page frame? An area in the main memory that...

What is page frame? An area in the main memory that can hold single page is called as page frame.

What do you mean by term procedure, What do you mean by term procedure? Dif...

What do you mean by term procedure? Differentiate between far call and near call? PROC: PROC and ENDP directives indicate the start and end of a procedure. These directives for

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