Variablesare declaredwiththefollowingformat datatype

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: variable name Key words/reserved words cannot be used as a variable name 2 2 Variable deceleration In C++, the variable must be declared first and it can be used then. variables are declared with the following format: datatype var1, var2,…; d a ta ty p e s in C ++ a re int, flo a t, c h a r e tc . int fo r inte g e r typ e va ria b le , flo a t fo r flo a ting p o int va ria b le a nd c h a r fo r c h a ra c te r typ e va ria b le 3 3 Memory location When a variable is used in a computer program, the computer When associates it with a particular memory location. In other words, a variable is a space in the computer’s memory In set aside for a certain kind of data and gives a name of reference set Void main() { int a; a=40 ----------} a 40 Memory 4 4 Types of variables C ++ la ng ua g e p ro vid e s th re e typ e s o f va ria b le s Inte g e r va ria b le Inte g e r va ria b le d e c la ra tio n s ta te m e nt h a s th e fo rm int sum; T h e d e c la ra tio n c o ns is ts o f th e d a ta ty p e na m e int, fo llo we d b y...
View Full Document

This document was uploaded on 03/16/2014.

Ask a homework question - tutors are online