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

Derivatives and applications of derivatives, What can you say about the exi...

What can you say about the existence of a stationary point in the interval [ 1; 3] for the function f (x) = x 2 2x 3.

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

Explain the importance of computer architecture, Explain the importance of ...

Explain the importance of computer architecture Studying the architecture implies working on machine language programs. However, this isn't practical when we design a computer

Dfa, design a dfa which accept all the string over a and b ending with ab o...

design a dfa which accept all the string over a and b ending with ab or ba

Convert a JK flipflop to T type flipflop, With the help of a suitable diagr...

With the help of a suitable diagram, explain how do you convert a JK flipflop to T type flipflop. Ans. As here flip flop is JK flip flop and it is required to convert JK in T.

Types of assemblies, How many types of assemblies are there? Private, P...

How many types of assemblies are there? Private, Public/Shared, Satellite. A private assembly is normally used by a one application, and is stored in the application's director

How is basic authentication worked, How is basic authentication worked? ...

How is basic authentication worked? When an exact resource has been protected using fundamental authentication, Apache sends a 401 Authentication needed header along with the r

Importance of using module-instance parameter, Using Module-Instance Parame...

Using Module-Instance Parameter: Parameter values can be overridden while a module is instantiated. New parameter values are passed at the time of module instantiation. Top-

How to use data validation function in vba, Data validation is a significan...

Data validation is a significant concept in VBA. Application process and a custom dialog box can be used to accurate input errors. You can assign an application process to the fram

Analysts in various functional areas, Q. Analysts in various functional are...

Q. Analysts in various functional areas? Today systems analyst's job presents a exciting and fascinating challenge. It provides high management visibility and opportunities 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