Engineering Forum

India Education

Engineering Colleges Forum

Variables, Types and Expressions

This is a discussion on Variables, Types and Expressions within the Computer engineering forums, part of the ENGINEERING WORLD category; Identifiers As we have seen, C++ programs can be written using many English words. It is useful to think of ...


Go Back   Engineering Forum > ENGINEERING WORLD > Computer engineering

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

   

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 08-28-2008, 07:41 PM
aayush_005's Avatar
Administrator
 
Join Date: Aug 2008
Posts: 225
Default Variables, Types and Expressions

Identifiers


As we have seen, C++ programs can be written using many English words. It is useful to think of words found in a program as being one of three types:
Reserved Words. These are words such as if, int and else, which have a predefined meaning that cannot be changed. Here's a more complete list:
asm continue float new signed try

auto default for operator sizeof typedef

break delete friend private static union

case do goto protected struct unsigned

catch double if public switch virtual

char else inline register template void

class enum int return this volatile

const extern long short throw while

using namespace bool static_cast const_cast dynamic_cast

true false
Click here to group these words into categories.

Library Identifiers. These words are supplied default meanings by the programming environment, and should only have their meanings changed if the programmer has strong reasons for doing so. Examples are cin, cout and sqrt (square root).
Programmer-supplied Identifiers. These words are "created" by the programmer, and are typically variable names, such as year_now and another_age.

An identifier cannot be any sequence of symbols. A valid identifier must start with a letter of the alphabet or an underscore ("_") and must consist only of letters, digits, and underscores.

(BACK TO COURSE CONTENTS)



2.2 Data Types

Integers


C++ requires that all variables used in a program be given a data type. We have already seen the data type int. Variables of this type are used to represent integers (whole numbers). Declaring a variable to be of type int signals to the compiler that it must associate enough memory with the variable's identifier to store an integer value or integer values as the program executes. But there is a (system dependent) limit on the largest and smallest integers that can be stored. Hence C++ also supports the data types short int and long int which represent, respectively, a smaller and a larger range of integer values than int. Adding the prefix unsigned to any of these types means that you wish to represent non-negative integers only. For example, the declaration
unsigned short int year_now, age_now, another_year, another_age;

reserves memory for representing four relatively small non-negative integers.

Some rules have to be observed when writing integer values in programs:
Decimal points cannot be used; although 26 and 26.0 have the same value, "26.0" is not of type "int".
Commas cannot be used in integers, so that (for example) 23,897 has to be written as "23897".
Integers cannot be written with leading zeros. The compiler will, for example, interpret "011" as an octal (base 8) number, with value 9.

(BACK TO COURSE CONTENTS)



Real numbers


Variables of type "float" are used to store real numbers. Plus and minus signs for data of type "float" are treated exactly as with integers, and trailing zeros to the right of the decimal point are ignored. Hence "+523.5", "523.5" and "523.500" all represent the same value. The computer also accepts real numbers in floating-point form (or "scientific notation"). Hence 523.5 could be written as "5.235e+02" (i.e. 5.235 x 10 x 10), and -0.0034 as "-3.4e-03". In addition to "float", C++ supports the types "double" and "long double", which give increasingly precise representation of real numbers, but at the cost of more computer memory.

Type Casting


Sometimes it is important to guarantee that a value is stored as a real number, even if it is in fact a whole number. A common example is where an arithmetic expression involves division. When applied to two values of type int, the division operator "/" signifies integer division, so that (for example) 7/2 evaluates to 3. In this case, if we want an answer of 3.5, we can simply add a decimal point and zero to one or both numbers - "7.0/2", "7/2.0" and "7.0/2.0" all give the desired result. However, if both the numerator and the divisor are variables, this trick is not possible. Instead, we have to use a type cast. For example, we can convert "7" to a value of type double using the expression "static_cast<double>(7)". Hence in the expression
answer = static_cast<double>(numerator) / denominator

the "/" will always be interpreted as real-number division, even when both "numerator" and "denominator" have integer values. Other type names can also be used for type casting. For example, "static_cast<int>(14.35)" has an integer value of 14.

(BACK TO COURSE CONTENTS)



Characters


Variables of type "char" are used to store character data. In standard C++, data of type "char" can only be a single character (which could be a blank space). These characters come from an available character set which can differ from computer to computer. However, it always includes upper and lower case letters of the alphabet, the digits 0, ... , 9, and some special symbols such as #, £, !, +, -, etc. Perhaps the most common collection of characters is the ASCII character set (see for example Savitch, page 978 or just click here).

Character constants of type "char" must be enclosed in single quotation marks when used in a program, otherwise they will be misinterpreted and may cause a compilation error or unexpected program behaviour. For example, "'A'" is a character constant, but "A" will be interpreted as a program variable. Similarly, "'9'" is a character, but "9" is an integer.

There is, however, an important (and perhaps somewhat confusing) technical point concerning data of type "char". Characters are represented as integers inside the computer. Hence the data type "char" is simply a subset of the data type "int". We can even do arithmetic with characters. For example, the following expression is evaluated as true on any computer using the ASCII character set:

'9' - '0' == 57 - 48 == 9

The ASCII code for the character '9' is decimal 57 (hexadecimal 39) and the ASCII code for the character '0' is decimal 48 (hexadecimal 30) so this equation is stating that

57(dec) - 48(dec) == 39(hex) - 30(hex) == 9

It is often regarded as better to use the ASCII codes in their hexadecimal form.

However, declaring a variable to be of type "char" rather than type "int" makes an important difference as regards the type of input the program expects, and the format of the output it produces. For example, the program
#include <iostream>
using namespace std;

int main()
{
int number;
char character;

cout << "Type in a character:\n";
cin >> character;

number = character;

cout << "The character '" << character;
cout << "' is represented as the number ";
cout << number << " in the computer.\n";

return 0;
}

Program 2.2.1

produces output such as
Type in a character:
9
The character '9' is represented as the number 57 in the computer.


We could modify the above program to print out the whole ASCII table of characters using a "for loop". The "for loop" is an example of a repetition statement - we will discuss these in more detail later. The general syntax is:
for (initialisation; repetition_condition ; update) {
Statement1;
...
...
StatementN;
}

C++ executes such statements as follows: (1) it executes the initialisation statement. (2) it checks to see if repetition_condition is true. If it isn't, it finishes with the "for loop" completely. But if it is, it executes each of the statements Statement1 ... StatementN in turn, and then executes the expression update. After this, it goes back to the beginning of step (2) again.

We can also 'manipulate' the output to produce the hexadecimal code. Hence to print out the ASCII table, the program above can be modified to:
#include <iostream>
using namespace std;

int main()
{
int number;
char character;

for (number = 32 ; number <= 126 ; number = number + 1) {

character = number;
cout << "The character '" << character;
cout << "' is represented as the number ";
cout << dec << number << " decimal or "
<<hex<<number<< " hex.\n";
}

return 0;
}

Program 2.2.2

which produces the output:
The character ' ' is represented as the number 32 decimal or 20 hex.
The character '!' is represented as the number 33 decimal or 21 hex.
...
...
The character '}' is represented as the number 125 decimal or 7D hex.
The character '~' is represented as the number 126 decimal or 7E hex.


(BACK TO COURSE CONTENTS)



Strings


Our example programs have made extensive use of the type "string" in their output. As we have seen, in C++ a string constant must be enclosed in double quotation marks. Hence we have seen output statements such as

cout << "' is represented as the number ";

in programs. In fact, "string" is not a fundamental data type such as "int", "float" or "char". Instead, strings are represented as arrays of characters, so we will return to subject of strings later, when we discuss arrays in general.

User Defined Data Types


Later in the course we will study the topic of data types in much more detail. We will see how the programmer may define his or her own data types. This facility provides a powerful programming tool when complex structures of data need to be represented and manipulated by a C++ program.

(BACK TO COURSE CONTENTS)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2011, 04:46 AM
Junior Member
 
Join Date: Jan 2011
Posts: 5
Default

C++ requires that all variables used in a program be given a data type. We have already seen the data type int. Variables of this type are used to represent integers (whole numbers). Declaring a variable to be of type int signals to the compiler that it must associate enough memory with the variable's identifier to store an integer value or integer values as the program executes. This is really very important.
__________________
taxi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-23-2011, 11:27 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default cialis erectile disfunctioncialis information for cialis

Cooking practices can also affect the development of food allergies.What is surprising is that only three-quarters of the children and less than half of the adults in this study sought a medical evaluation of the allergy despite reporting severe reactions and multiple reactions during their lifetime.order generic Zithromax online The 3 or 4 days are all the same.People with allergy symptoms -- such as the runny nose of allergic rhinitis -- may at first suspect they have a cold, but the "cold" lingers on.Most cases of winter itch are a result of dry skin from the drier air found during sustained periods of cold weather.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-24-2011, 10:07 AM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

They must now figure out how pet exposure causes a general shift of the immune system away from an allergic response.Self-prescribed and physician-prescribed medications are important causes of allergic contact dermatitis.Rather than involving multiple sinuses, a fungus ball typically involves a single sinus, most often the maxillary antrum or sphenoid. Evidence is now mounting that there is a rise in the occurrence of food allergies that appears to parallel the rise in other allergic diseases.On most days, I seem a little better by about 10:30 a.Older persons have drier and thinner skin that does not tolerate soaps and solvents as well as younger individuals.
<a href="http://caltentportgen.onsugar.com/bangkok-cialis-14296031">bangkok cialis </a><a href="http://unrievego.onsugar.com/improved-soft-cialis-14363072">improved soft cialis </a><a href="http://viapreexsiaschil.onsugar.com/tadalafil-cialis-apcalis-regalis-14291416">tadalafil cialis apcalis regalis </a><a href="http://banksimpsarhhe.onsugar.com/cialis-similar-14361680">cialis similar </a><a href="http://itdithoti.onsugar.com/cialis-street-value-14356755">cialis street value </a><a href="http://lesmujorchi.onsugar.com/bestellen-cialis-14290530">bestellen cialis </a><a href="http://terethednock.onsugar.com/cialis-zoloft-interactions-14358637">cialis and zoloft interactions </a>
Little is known about the pathophysiology of nummular dermatitis, but it is frequently accompanied by xerosis.NSAIDs such as ibuprofen may cause ulcers, bleeding, or holes in the stomach or intestine.Scibilia J, Pastorello EA, Zisa G, Ottolenghi A, Bindslev-Jensen C, Pravettoni V, Scovena E, Robino A, Ortolani C.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-24-2011, 02:04 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

The mom and the other two children experience no reaction whatsoever to the presence of the cat.It seems that when I wet my hair and wash may face, my throat immediately itches.Allergies can trigger or worsen asthma and lead to other health problems, such as sinusitis and ear infections in children. Sweating and friction appear to be the main cause of dermatitis that appears under soccer shin guards in children.These patients report both itching and pain caused by fissuring of the hyperkeratotic skin (chapping).For example, certain food allergies can be prevented by not eating the food.
<a href="http://anuncobfo.onsugar.com/cialis-priapism-14300722">cialis priapism </a><a href="http://suruptipe.onsugar.com/where-order-cialis-online-14287770">where to order cialis online </a><a href="http://komdelita.onsugar.com/cialis-online-fda-14306023">cialis online fda </a><a href="http://toyboyxancu.onsugar.com/cialis-soft-tabs-online-pharmacy-14295888">cialis soft tabs online pharmacy </a><a href="http://sucmeograckas.onsugar.com/viagra-vs-cialis-14356624">viagra vs. cialis </a><a href="http://lieboylilo.onsugar.com/development-cost-cialis-14289665">development cost of cialis </a><a href="http://cycbumarkla.onsugar.com/cialis-patent-protection-14363416">cialis patent protection </a>
For example, a patient allergic to neomycin may develop systemic contact dermatitis if treated with intravenous gentamicin.When I eat these foods within a few hours to as little as 20 minutes I start to clear my throat.Doctors often recommend this medicine for the relief of allergies in children because it is extremely safe and available without a prescription.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-24-2011, 02:30 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

Do not give nonprescription ibuprofen to a child who has a sore throat that is severe or does not go away, or that comes along with fever, headache, nausea, or vomiting.The next time the allergen encounters its specific IgE, it attaches to the antibody like a key fitting into a lock.However, standardization of extracts for cat dander and dust mites, and overall better preparations, have increased the effectiveness of the shots even for these patients. An alcohol-based hand-cleansing gel may even decrease, rather than increase, skin irritation after a hand wash, owing to a mechanical partial elimination of the detergent.Therefore, people who are prone to allergies are said to be allergic or "atopic.When evaluating the average ages and sex ratios of other studies, series with younger average ages are more likely to have a male predominance.
<a href="http://grocicfrenvi.onsugar.com/anything-increase-cialis-effectiveness-14304675">anything increase cialis effectiveness </a><a href="http://listpizbobbti.onsugar.com/shelf-life-cialis-14358813">shelf life of cialis </a><a href="http://phelilightal.onsugar.com/cialis-generic-tadalafil-best-price-compare-14315974">cialis generic tadalafil best price compare </a><a href="http://aqalflexaf.onsugar.com/cialis-one-aday-14302249">cialis one aday </a><a href="http://amsenmildpa.onsugar.com/cost-cialis-cvs-14310046">cost of cialis cvs </a><a href="http://komdelita.onsugar.com/cialis-approval-fda-14306050">cialis approval fda </a><a href="http://gagtarunci.onsugar.com/cialis-mutliple-orgasm-14357163">cialis mutliple orgasm </a>
Long-term use of systemic corticosteroids to treat allergic contact dermatitis may produce severe morbidity.Management consisted of extensive surgical debridement followed by therapy with systemic and topical antifungal agents.Minor objective criteria for irritant contact dermatitis include the following:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-24-2011, 02:52 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

This has happened at least 8 times in past 5 years.On most days, I seem a little better by about 10:30 a.Thick fungal debris and mucin, as shown below, are developed in the sinus cavities and must be surgically removed so that the inciting allergen is no longer present. Erythema, edema, vesiculation, hyperpigmentation, and desquamation are typical phototoxic skin effects.Apart from the bergamot lime, bergapten also is a component in other substances, inducing bergapten phototoxicity without the typical pendantlike appearance of berloque dermatitis.If you are interested in seeing a complete listing of all support groups in the U.
<a href="http://hasttirico.onsugar.com/generic-cialis-absolute-lowest-price-14355744">generic cialis absolute lowest price </a><a href="http://bausaynepli.onsugar.com/generic-cialis-trial-size-14298066">generic cialis trial size </a><a href="http://onlettimi.onsugar.com/manage/new">cialis with atenolol </a><a href="http://heilolone.onsugar.com/generic-cialis-sweet-14356381">generic cialis sweet </a><a href="http://colrigarre.onsugar.com/all-natural-cialis-14301236">all natural cialis </a><a href="http://tekacomligh.onsugar.com/what-does-street-cialis-look-like-14300364">what does street cialis look like </a><a href="http://mulrosigge.onsugar.com/cialis-time-release-14316505">cialis time release </a>
If you give a patient allergy shots for only a year or 2, even if they've had a good year, there's some indication that the relapse rate might be higher.Ibuprofen is also sometimes used to treat ankylosing spondylitis (arthritis that mainly affects the spine), gouty arthritis (joint pain caused by a build-up of certain substances in the joints), and psoriatic arthritis (arthritis that occurs with a long-lasting skin disease that causes scaling and swelling).Use the Support Group Lookup Tool, below, to contact groups directly.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-24-2011, 03:15 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

Nummular dermatitis is characterized by round-to-oval erythematous plaques most commonly found on the arms and legs.* Lesions begin as erythematous-to-violaceous papules or vesicles, which then coalesce to form confluent plaques.When evaluating for food allergy or other allergic problems, it is not uncommon for an allergist to test for foods that a patient has never knowingly eaten or is eating without obvious problems. If a doctor has precribed an epinephrine auto-injector, be sure you know how to use it, and carry it with you at all times!Another major piece of the allergy puzzle is the environment.Individuals allergic to nickel occasionally may develop vesicles on the sides of the fingers (dyshidrotic hand eczema or pompholyx) from nickel in the diet.
<a href="http://kimdevisi.onsugar.com/cheap-cialis-si-14290687">cheap cialis si </a><a href="http://softrlinuapin.onsugar.com/cialis-samples-voucher-14321314">cialis samples voucher </a><a href="http://dafizalu.onsugar.com/new-life-cialis-14288244">new life cialis </a><a href="http://bausaynepli.onsugar.com/subaction-showcomments-cialis-optional-online-14297989">subaction showcomments cialis optional online </a><a href="http://risksontebe.onsugar.com/q-cialis-kgs-0-kls-0-14300281">q cialis kgs 0 kls 0 </a><a href="http://sulgimotemb.onsugar.com/cialis-same-tadalafil-14356749">cialis same as tadalafil </a><a href="http://biosticopbar.onsugar.com/does-cialis-work-women-14306827">does cialis work women </a>
The immediate onset of dermatitis following initial exposure to material suggests either a cross-sensitization reaction, prior forgotten exposure to the substance, or nonspecific irritant contact dermatitis provoked by the agent in question.* Macular erythema, hyperkeratosis, or fissuring predominating over vesiculationHigh-risk occupations include cleaning, hospital care, food preparation, and hairdressing.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-24-2011, 03:51 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

Our webinar provides you with the essential information you need to get started.As always, feel free to contact FAAN if you have any questions or if we can be of any help to you and your family.If you are having surgery, including dental surgery, tell the doctor or dentist that you are taking ibuprofen. The reaction can be evoked in all subjects as long as the concentration of the chemical and the dose of light are sufficient.Management consisted of extensive surgical debridement followed by therapy with systemic and topical antifungal agents.* Secondary infection may result in lesions that ooze serosanguineous exudate.
<a href="http://perpoderto.onsugar.com/cialis-online-reviews-14310171">cialis online reviews </a><a href="http://acprecrallta.onsugar.com/cialis-pills-premature-ejaculation-14310512">cialis pills premature ejaculation </a><a href="http://liamidelea.onsugar.com/cialis-neurological-effects-14361085">cialis neurological effects </a><a href="http://resgiggteentva.onsugar.com/cialis-beograd-14289304">cialis beograd </a><a href="http://suifreechoxtvun.onsugar.com/generic-cialis-reviews-14361835">generic cialis reviews </a><a href="http://marbicarlda.onsugar.com/cialis-overnight-new-york-14309380">cialis overnight new york </a><a href="http://vamcapercreemp.onsugar.com/2cialis-levitra-sales-viagra-14313602">2cialis levitra sales viagra </a>
It is important for you to keep a written list of all of the prescription and nonprescription (over-the-counter) medicines you are taking, as well as any products such as vitamins, minerals, or other dietary supplements.If you have phenylketonuria (PKU, an inborn disease in which mental retardation develops if a specific diet is not followed), read the package label carefully before taking nonprescription ibuprofen.Direct evidence for the increase in food allergies comes from two studies that focus specifically on peanut allergy.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-24-2011, 04:26 PM
Senior Member
 
Join Date: Feb 2011
Posts: 957
Default

In the review of patients at UT Southwestern, in children, males dominated (M/F ratio 2.A 15-year-old boy with allergic fungal sinusitis causing right proptosis, telecanthus, and malar flattening; the position of his eyes is asymmetrical, and his nasal ala on the right is pushed inferiorly compared to the left.Severe local reactions from PPD may occur in black henna tattoos in adults and children. Fragrances are found not only in perfumes, colognes, aftershaves, deodorants, and soaps, but also in numerous other products, often as a mask to camouflage an unpleasant odor.Instruct school staff to follow your child’s FAAP immediately – not to call you to assess the situation.Usually, a cutoff of dermatitis occurs on the forearms where skin is no longer in contact with the gloves.
<a href="http://consbuddhamys.onsugar.com/do-insurance-companies-cover-cialis-14296219">do insurance companies cover cialis </a><a href="http://widlephowhi.onsugar.com/buy-cialis-pharmacy-online-14286378">buy cialis pharmacy online </a><a href="http://didisdiater.onsugar.com/bph-cialis-14357274">bph cialis </a><a href="http://toaresepou.onsugar.com/get-cialis-without-prescription-14310760">get cialis without prescription </a><a href="http://meforpangsi.onsugar.com/cialis-daily-prices-14314638">cialis daily prices </a><a href="http://giotricopach.onsugar.com/cialis-pill-online-14308380">cialis pill online </a><a href="http://tekacomligh.onsugar.com/cialis-online-online-get-cialis-cheapest-14300358">cialis online online get cialis cheapest </a>
Because development of proptosis usually occurs over long periods, no diplopia or visual loss generally is seen.These powerful chemicals cause certain cells within some blood vessels in the nose to contract.All patients with allergic fungal sinusitis (AFS) should undergo surgical debridement of their sinuses.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT. The time now is 09:32 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.