<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;AkICRno6cSp7ImA9WhRTE0w.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968</id><updated>2011-11-03T04:09:27.419-07:00</updated><title>CSE-Kids</title><subtitle type='html'>A blog on computing fundamentals especially written for an absolute beginner in தமிழ் language.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;CEABRX8_eSp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-6923847788531225644</id><published>2011-08-04T08:45:00.001-07:00</published><updated>2011-08-04T08:45:54.141-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:45:54.141-07:00</app:edited><title>WHAT IS C++?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
You can see that the C programming language was developed first, C++&lt;br /&gt;
was developed later. You might be asking yourself what, exactly, is C++&lt;br /&gt;
and how does it relate to C? The answer is that C++ is essentially C taken&lt;br /&gt;
to the next level. The most obvious difference between the two is that&lt;br /&gt;
C++ supports object orientation (more on that in Chapters 10, 11, and 12).&lt;br /&gt;
However, C++ sports many other improvements over C. For example,&lt;br /&gt;
C++ handles strings better than C, and has a more robust exception handling.&lt;br /&gt;
(Exception handling refers to a program’s ability to handle unexpected&lt;br /&gt;
errors. What if the user inputs a zero then tries to divide by that&lt;br /&gt;
number? This is an exception, how your code handles it is exception handling.&lt;br /&gt;
Chapter 7 discusses this topic in depth.)&lt;br /&gt;
C code will compile fine in most C++ compilers, but the reverse is not&lt;br /&gt;
true. C++ code will not necessarily compile in a C compiler. You may be&lt;br /&gt;
wondering what is meant by the word code. Code is essentially the series&lt;br /&gt;
of programming commands that a programmer writes. All the commands&lt;br /&gt;
that make up a program are the source code for that program.&lt;br /&gt;
C++ supports all C commands and also has many additions. You may&lt;br /&gt;
frequently see old style C code mixed in with C++ code, especially in programs&lt;br /&gt;
written by programmers who originally started in C.&lt;br /&gt;
HOW TO&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-6923847788531225644?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/6923847788531225644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/what-is-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6923847788531225644?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6923847788531225644?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/what-is-c.html' title='WHAT IS C++?'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEEBRH4_fSp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-5830769610437051205</id><published>2011-08-04T08:44:00.000-07:00</published><updated>2011-08-04T08:44:15.045-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:44:15.045-07:00</app:edited><title>HISTORY OF C++</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
C++, as the name implies, is essentially based on the C programming language.&lt;br /&gt;
Therefore, it seems prudent to begin with a brief history of C. The&lt;br /&gt;
C programming language was devised in the early 1970s at Bell Laboratories&lt;br /&gt;
by Dennis Ritchie. It was designed as a system implementation language&lt;br /&gt;
for the Unix operating system. The history of C and Unix are&lt;br /&gt;
closely intertwined. For this reason a lot of Unix programming is done&lt;br /&gt;
with C. To some extent, C was originally based on the typeless language&lt;br /&gt;
BCPL, however it grew well beyond that.&lt;br /&gt;
The C++ programming language was invented by Bjarne Stroustroup.&lt;br /&gt;
Work on what would become C++ began in 1979. The initial version was&lt;br /&gt;
called “C with Classes.” That name did not work out well, and was&lt;br /&gt;
replaced with C++. The first version of C++ was used internally in AT&amp;amp;T&lt;br /&gt;
in August 1983. The first commercial implementation was released in&lt;br /&gt;
1985. The C++ language standards are now handled by the American&lt;br /&gt;
National Standards Institute (ANSI), and the International Standards&lt;br /&gt;
Organization (ISO). This is why you often hear pure C++ referred to as&lt;br /&gt;
ANSI Standard C++, or ISO Standard C++.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-5830769610437051205?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/5830769610437051205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/history-of-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/5830769610437051205?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/5830769610437051205?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/history-of-c.html' title='HISTORY OF C++'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEICQn88fCp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-6099631137789440496</id><published>2011-08-04T08:42:00.001-07:00</published><updated>2011-08-04T08:42:43.174-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:42:43.174-07:00</app:edited><title>HOW TO WRITE A C++ PROGRAM</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
There are several ways to write a C++ program. You could simply open&lt;br /&gt;
your favorite text editor, such as notepad, write your program, save it, and&lt;br /&gt;
then use a command line compiler to compile the program. In fact, this is&lt;br /&gt;
the method that will be used in this book, until we get to Section IV, the&lt;br /&gt;
section on Visual C++. If you have a commercial development tool such&lt;br /&gt;
as Borland C++ Builder™ or Microsoft Visual C++,™then you must&lt;br /&gt;
follow the instructions for that particular software package. The examples&lt;br /&gt;
in this book will use the free downloadable version of the Borland&lt;br /&gt;
C++ compiler. The free Borland C++ compiler does not have the extra&lt;br /&gt;
development tools and IDE (Integrated Development Environment) that&lt;br /&gt;
Borland C++ Builder has. The Web address to go to and download this&lt;br /&gt;
free C++ compiler is listed in Appendix A. However, the free download&lt;br /&gt;
is simply a command line compiler. A command line compiler is one that&lt;br /&gt;
is executed from the command line. This, of course, begs the question of&lt;br /&gt;
what is a command line. When you enter commands at a DOS prompt&lt;br /&gt;
(Microsoft Windows™98), Command Prompt (Microsoft Windows&lt;br /&gt;
2000/XP), or Shell (Linux/Unix™) you are typing commands on a line,&lt;br /&gt;
thus the term “command line.” You literally type in commands one line&lt;br /&gt;
at a time. Figure 1.1 shows the basic DOS prompt for Windows 95/98™.&lt;br /&gt;
To use a command line compiler, like the free C++ compiler from Borland,&lt;br /&gt;
you simply type the code into a document in any text editor, then&lt;br /&gt;
save it with a .cpp extension (e.g., myprogram.cpp). That .cpp extension&lt;br /&gt;
stands for C Plus Plus. C files that are done in a text editor are saved with&lt;br /&gt;
the extension .c, as you might expect. Complete instructions for how to&lt;br /&gt;
download, install, configure, and use this compiler can be found in&lt;br /&gt;
Appendix D. You should use the instructions in Appendix D to make&lt;br /&gt;
&lt;br /&gt;
sure you have the compiler properly installed on your PC before continuing&lt;br /&gt;
with this book.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-6099631137789440496?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/6099631137789440496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/how-to-write-c-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6099631137789440496?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6099631137789440496?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/how-to-write-c-program.html' title='HOW TO WRITE A C++ PROGRAM'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEMBQXk9eSp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-847640400922849548</id><published>2011-08-04T08:40:00.000-07:00</published><updated>2011-08-04T08:40:50.761-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:40:50.761-07:00</app:edited><title>C++ FUNDAMENTALS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
C++ is a programming language. As such, it shares a number of similarities&lt;br /&gt;
with other programming languages. First we may need to clarify&lt;br /&gt;
what a programming language is. A computer thinks in 1’s and 0’s. Various&lt;br /&gt;
switches are either on (1’s), or off (0’s). Most humans, however,&lt;br /&gt;
have trouble thinking in 1’s and 0’s. A programming language is a language&lt;br /&gt;
that provides a bridge between the computer and human beings.&lt;br /&gt;
A “low-level” language is one that is closer to a computer’s thinking&lt;br /&gt;
than to a human language. A prime example would be Assembly language.&lt;br /&gt;
A “high-level” language is one that is closer to human language.&lt;br /&gt;
COBOL and BASIC are prime examples of high-level language.&lt;br /&gt;
&lt;br /&gt;
people consider C and C++ to be high-level languages, but actually C&lt;br /&gt;
and C++ are both somewhat of a bridge between the low-level languages&lt;br /&gt;
and high-level languages. You might think of them as mid-level&lt;br /&gt;
languages. The level of a language, in this context, essentially refers to&lt;br /&gt;
how far it is removed from actual machine language. It has no relationship&lt;br /&gt;
to either the power of the programming language, or the difficulty&lt;br /&gt;
of learning and using it. Various languages, with their basic level indicated,&lt;br /&gt;
&lt;br /&gt;
are shown in Figure 1.2.&lt;br /&gt;
Each programming language has various strengths and weaknesses.&lt;br /&gt;
Some, like BASIC, are easy to use but are neither flexible nor powerful.&lt;br /&gt;
Others, such as Assembly, are powerful, but difficult to use. C and C++&lt;br /&gt;
are somewhere in the middle. C++ is quite powerful, but relatively easy&lt;br /&gt;
to use (easier than Assembly but more difficult than BASIC). Some languages&lt;br /&gt;
are also written with specific purposes in mind. Fortran was&lt;br /&gt;
written specifically for mathematical programming, BASIC was&lt;br /&gt;
designed simply for teaching programming, and COBOL was designed&lt;br /&gt;
&lt;br /&gt;
for business applications. C++ was designed as a general purpose language.&lt;br /&gt;
It is used in business applications, telecommunications programming,&lt;br /&gt;
artificial intelligence programming, games programming, and&lt;br /&gt;
much more. This is one reason why it is the language that many teachers&lt;br /&gt;
choose to teach students. Once you have learned C++, you can use it in a&lt;br /&gt;
wide variety of situations.&lt;br /&gt;
Programs are written to handle data. This is why the industry as a&lt;br /&gt;
whole is often referred to as data processing, information technology,&lt;br /&gt;
computer information systems, and so on. That data might be information&lt;br /&gt;
about employees, parts to a mathematical computation, scientific&lt;br /&gt;
data, or even the elements of a game. No matter what programming language&lt;br /&gt;
or techniques you use, the ultimate goal of programming is to&lt;br /&gt;
store, manipulate, and retrieve data. Data must be temporarily stored in&lt;br /&gt;
the program, in order to be manipulated. This is accomplished via variables.&lt;br /&gt;
A variable is simply a place in memory set aside to hold data of a&lt;br /&gt;
particular type. It is a specific section of the computer’s memory that has&lt;br /&gt;
been reserved to hold some data. It is called a variable because its value&lt;br /&gt;
or content can vary. When you create a variable, you are actually setting&lt;br /&gt;
aside a small piece of memory for storage purposes. The name you give&lt;br /&gt;
the variable is actually a label for that address in memory. For example,&lt;br /&gt;
you might declare a variable in the following manner.&lt;br /&gt;
int j;&lt;br /&gt;
Then, you have just allocated four bytes of memory; you are using the&lt;br /&gt;
variable j to refer to those four bytes of memory. You are also stating that&lt;br /&gt;
the only type of data that j will hold, is whole numbers. (The int is a data&lt;br /&gt;
type that refers to integers, or whole numbers.) Now, whenever you reference&lt;br /&gt;
j in your code, you are actually referencing the contents being&lt;br /&gt;
stored at a specific address in memory.&lt;br /&gt;
With that said, you might now be asking what is meant by “data of a&lt;br /&gt;
particular type”? Data comes in different types. Some data consists of letters&lt;br /&gt;
and some consists of numbers. Any programming language will recognize&lt;br /&gt;
only certain types or categories of data. The basic data types that&lt;br /&gt;
C++ recognizes, and what they hold, are shown in Table 1.1. In addition,&lt;br /&gt;
there are a few other data types that will be introduced later in the book.&lt;br /&gt;
When you are deciding what type of variable to create, you need to&lt;br /&gt;
think about what kind of data you might wish to store in that variable. If&lt;br /&gt;
you want to store a person’s age, then an int is a good choice. The int&lt;br /&gt;
data type will hold whole numbers, and will, in fact, hold numbers much&lt;br /&gt;
larger than you might need for a person’s age. The long data type will&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-847640400922849548?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/847640400922849548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/c-fundamentals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/847640400922849548?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/847640400922849548?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/c-fundamentals.html' title='C++ FUNDAMENTALS'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CEYBSX05fSp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-6594509403906661342</id><published>2011-08-04T08:35:00.001-07:00</published><updated>2011-08-04T08:35:58.325-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:35:58.325-07:00</app:edited><title>STATEMENTS AND EXPRESSIONS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
As you have already seen, a statement is simply a single line of code that&lt;br /&gt;
performs some action. Remember that another word for a statement is an&lt;br /&gt;
expression. In C++, a single expression does some type of action. That&lt;br /&gt;
action might be to declare a variable, add two numbers, compare two&lt;br /&gt;
values, or just about anything at all. It is also important to remember that&lt;br /&gt;
all statements/expressions end with a semicolon. Another of the most&lt;br /&gt;
common mistakes that beginners make is leaving off semicolons. Let’s&lt;br /&gt;
look at a few simple statements.&lt;br /&gt;
int i_acctnum;&lt;br /&gt;
i_acctnum = 555555;&lt;br /&gt;
i_acctnum = i_acctnum + 5;&lt;br /&gt;
Each statement performs a different action—but it does perform some&lt;br /&gt;
action—and it ends with a semicolon. The first statement/expression&lt;br /&gt;
simply declares a variable. The second statement/expression sets that&lt;br /&gt;
variable equal to some value. Finally, the last statement/expression performs&lt;br /&gt;
addition and puts the answer in the variable that was previously&lt;br /&gt;
declared.&lt;br /&gt;
Operators&lt;br /&gt;
You saw, at the end of the last section, the use of the + sign. This is an&lt;br /&gt;
operator. An operator is simply some symbol that performs some action,&lt;br /&gt;
usually a mathematical action, such as addition or subtraction. C++ supports&lt;br /&gt;
a number of important operators that you will need to get&lt;br /&gt;
&lt;br /&gt;
with. Let’s begin examining C++ operators, starting with the basic math&lt;br /&gt;
operators, shown in Table 1.4.&lt;br /&gt;
TABLE 1.4 Operators&lt;br /&gt;
Operator Purpose Example&lt;br /&gt;
+ To add two numbers int answer;&lt;br /&gt;
answer = 5 +6;&lt;br /&gt;
- To subtract two numbers int answer;&lt;br /&gt;
answer = 10 –3;&lt;br /&gt;
* To multiply two numbers int answer;&lt;br /&gt;
answer = 4 * 5;&lt;br /&gt;
/ To divide two numbers int answer;&lt;br /&gt;
answer = 7/3;&lt;br /&gt;
++ This is a special operator that simply int answer;&lt;br /&gt;
increments the value by 1. You will see answer++;&lt;br /&gt;
this used later in this book when loops&lt;br /&gt;
are discussed.&lt;br /&gt;
-- This is also a special operator that simply int answer;&lt;br /&gt;
decrements the value by 1. answer--;&lt;br /&gt;
= The single equals sign is an assignment answer = 16;&lt;br /&gt;
operator. It states “make what’s on&lt;br /&gt;
the left equal to what’s on the right”&lt;br /&gt;
== The double equals is an equality operator. if(answer==5)&lt;br /&gt;
It asks “is what’s on the left equal to what’s&lt;br /&gt;
on the right?” This is frequently used in&lt;br /&gt;
if statements (which you will see in a&lt;br /&gt;
later chapter!)&lt;br /&gt;
!= Not equal to if (x !=3)&lt;br /&gt;
+= Add then assign x += 1;&lt;br /&gt;
-= Subtract then assign x -=1;&lt;br /&gt;
|| This is the logical OR operator. if(j == 5 || j ==10)&lt;br /&gt;
&amp;amp;&amp;amp; This is the logical AND operator if(j &amp;gt; 5 &amp;amp;&amp;amp; j&amp;lt;10)&lt;br /&gt;
&amp;gt;&amp;gt; Bitwise shift to the right 3&amp;lt;&amp;lt;2;&lt;br /&gt;
&amp;lt;&amp;lt; Bitwise shift to the left 3&amp;gt;&amp;gt;2;&lt;br /&gt;
&amp;amp; Bitwise And 3&amp;amp;2;&lt;br /&gt;
| Bitwise Or 3|&lt;br /&gt;
&lt;br /&gt;
Now using the expression,&lt;br /&gt;
answer = num++;&lt;br /&gt;
the value of num will first be put in answer, THEN incremented. In&lt;br /&gt;
other words, the value of answer will be set to 5, and then the value of num&lt;br /&gt;
will be incremented. If you want num to be incremented BEFORE you&lt;br /&gt;
assign the value to answer then you must put the increment operator first,&lt;br /&gt;
as shown in the following example.&lt;br /&gt;
answer = ++num;&lt;br /&gt;
The operators shown in Table 1.4 are your basic math operators and&lt;br /&gt;
logical operators. There are several other operators you will also see in&lt;br /&gt;
C++. These will be introduced in later chapters because they are pertinent&lt;br /&gt;
to topics that will be covered in those chapters. Most of the operators&lt;br /&gt;
in Table 1.4 should be familiar to you. The math operators represent&lt;br /&gt;
simple math operations. All math operators occur with a specific order.&lt;br /&gt;
The order is pretty much the same as the order of operations defined in&lt;br /&gt;
mathematics. First is * (multiplication), next / (division), then + (addition),&lt;br /&gt;
and, finally, – (subtraction). The increment ++ and decrement –&lt;br /&gt;
operators precedence is determined by what side of the variable they are&lt;br /&gt;
on. You can alter the order of operations by using parentheses, just as you&lt;br /&gt;
do in mathematics. An example follows.&lt;br /&gt;
answer = x * 3 + 4;&lt;br /&gt;
First, x and 3 would be multiplied, and then 4 would be added to that&lt;br /&gt;
product. If, instead, you wanted to add 3 and 4, then multiply by x, you&lt;br /&gt;
could simply use parentheses to denote that.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-6594509403906661342?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/6594509403906661342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/statements-and-expressions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6594509403906661342?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6594509403906661342?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/statements-and-expressions.html' title='STATEMENTS AND EXPRESSIONS'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C08ESHY4fCp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-560148452645368567</id><published>2011-08-04T08:30:00.001-07:00</published><updated>2011-08-04T08:30:09.834-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:30:09.834-07:00</app:edited><title>BASIC STRUCTURE OF A C++ PROGRAM</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have seen variable declaration, C++ expressions, and the&lt;br /&gt;
basic math operators, let’s take a quick look at the basic structure of a&lt;br /&gt;
C++ program. All C++ programs must have a main function. This is&lt;br /&gt;
where the program begins. Chapter 4 goes into greater detail regarding&lt;br /&gt;
functions. For now, suffice it to say that a function is one or more statements&lt;br /&gt;
grouped together in a logical manner to accomplish some goal&lt;br /&gt;
under a common name. Chapter 4 covers all the intricacies of C++ functions.&lt;br /&gt;
The following is a basic C++ program.&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
Now, this program will not do much—in fact, it won’t do anything&lt;br /&gt;
useful at all. It is, however, a valid C++ program. It has a main function&lt;br /&gt;
that returns an integer value. The main function is where all C++ programs&lt;br /&gt;
start. This is the starting point for your entire program. All main functions&lt;br /&gt;
are required by the ANSI (American National Standards Institute) standards&lt;br /&gt;
to return an integer. The integer is a 0 if the program executes fine,&lt;br /&gt;
and a 1 if some problem is encountered. This was originally done because&lt;br /&gt;
some operating systems require any program to return a value telling the&lt;br /&gt;
operating system that everything is OK. You will see a lot of Windows programmers&lt;br /&gt;
use a main function that returns a void like the following.&lt;br /&gt;
void main()&lt;br /&gt;
This will work in some cases, but it is not technically correct. This book&lt;br /&gt;
endeavors to conform to the ANSI standards and use return 0.&lt;br /&gt;
The next thing to notice about our sample program is the presence of&lt;br /&gt;
brackets. These brackets are C++’s way of establishing borders around&lt;br /&gt;
any block of code. (Incidentally, C, Java, and JavaScript™ do the same&lt;br /&gt;
thing. Learning it here will help you learn other languages as well.).&lt;br /&gt;
Every time you see an opening bracket, {there must be a matching}&lt;br /&gt;
closing bracket. You will see a lot more about this when we discuss loops,&lt;br /&gt;
decision structures, and functions. For now, suffice it to say that brackets&lt;br /&gt;
form borders around blocks of code.&lt;br /&gt;
With all that said, let’s look at a program that has a few statements.&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int j;&lt;br /&gt;
j = 5;&lt;br /&gt;
j++;&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
This simple program creates a variable named j, sets the value of that&lt;br /&gt;
variable to 5, then increments that value by one. This is still not a particularly&lt;br /&gt;
exciting piece of code, but it does illustrate the basic structure of a&lt;br /&gt;
C++ program. Three statements are executed, a 0 is returned to indicate&lt;br /&gt;
that everything is OK, and there are brackets surrounding the main function.&lt;br /&gt;
If you carefully examine this code, and follow this template in all&lt;br /&gt;
your programming, then you will do well!&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-560148452645368567?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/560148452645368567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/basic-structure-of-c-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/560148452645368567?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/560148452645368567?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/basic-structure-of-c-program.html' title='BASIC STRUCTURE OF A C++ PROGRAM'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0EMSHw8cCp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-6425261154703923825</id><published>2011-08-04T08:28:00.000-07:00</published><updated>2011-08-04T08:28:09.278-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:28:09.278-07:00</app:edited><title>Header Files</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;br /&gt;
There is only one more item that needs to be discussed regarding the&lt;br /&gt;
basic structure of a C++ program. That item is header files. Header files are&lt;br /&gt;
files that contain the definitions for functions and/or classes. Basically, if&lt;br /&gt;
you have a lot of functions or variables that you might want to use in several&lt;br /&gt;
programs, you can put them in a header file, then include that header&lt;br /&gt;
file anywhere you need to use it. After creating a header file you can then&lt;br /&gt;
include a reference to a header file in your program and use the functions&lt;br /&gt;
and/or classes defined in that header file. The real intricacies of header&lt;br /&gt;
files are discussed in a later chapter, in which you will actually create&lt;br /&gt;
some header files. However, you should realize that there are a lot of&lt;br /&gt;
these files built into C++ that you can use! Well, “built in” is not exactly&lt;br /&gt;
accurate. They are actually installed with your compiler and you can&lt;br /&gt;
include them in your programs. One of which you will use in Chapter 2 is&lt;br /&gt;
the iostream header file. It gives you functions to handle input and&lt;br /&gt;
output from the screen. The way you include any header file is simple. At&lt;br /&gt;
the beginning of your file, you reference the header file. This is demonstrated&lt;br /&gt;
in the following&lt;br /&gt;
&amp;nbsp;example.&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
You now have access to all the classes and functions defined in the&lt;br /&gt;
iostream header file. In the following chapters, you will see several different&lt;br /&gt;
header files, each providing a different set of functions for you to&lt;br /&gt;
use. For now, all that is important is that you realize that you include a&lt;br /&gt;
header file using the # sign and the word include. If the header file is one&lt;br /&gt;
that is part of C++, then you simply use the &amp;lt;headerfilename&amp;gt;. Make&lt;br /&gt;
sure that this is the first thing you do in your file! Remember that you use&lt;br /&gt;
.cpp to indicate a C++ source file and .c to indicate a C source file, while&lt;br /&gt;
the .h indicates a header source file. A source file is simply a plain text file&lt;br /&gt;
that has the source code for your C++ program. Source code is the basic&lt;br /&gt;
lines of programming language that you write, and that the compiler will&lt;br /&gt;
later use as a source to create an executable program.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-6425261154703923825?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/6425261154703923825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/header-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6425261154703923825?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/6425261154703923825?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/header-files.html' title='Header Files'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0IHRn86cCp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-7935662400574941697</id><published>2011-08-04T08:25:00.001-07:00</published><updated>2011-08-04T08:25:37.118-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:25:37.118-07:00</app:edited><title>FUNCTION BASICS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;br /&gt;
What are functions? In simple terms, a function is a block of code that is&lt;br /&gt;
identified by some name and can take zero or more parameters and can&lt;br /&gt;
return some value. That definition probably does little to clarify the issue&lt;br /&gt;
for you! Let’s look at a function and its parts to help clarify this issue. To&lt;br /&gt;
begin with, consider the following function, which squares a number.&lt;br /&gt;
float square(float num)&lt;br /&gt;
{&lt;br /&gt;
float answer = num * num;&lt;br /&gt;
return answer;&lt;br /&gt;
}&lt;br /&gt;
The first line of the function is called its declaration line. It has three parts.&lt;br /&gt;
The first part is its return type. The return type tells you what kind of data&lt;br /&gt;
the function will give you back. If it returns nothing, then its return type&lt;br /&gt;
would be void. In the previous example, the function will return the answer&lt;br /&gt;
to our math problem, and that is a float. The second thing is the name of the&lt;br /&gt;
function. Function names follow the same guidelines as variable names. It is&lt;br /&gt;
a good idea to have the function name reflect what the function will do.&lt;br /&gt;
Next, inside the parenthesis, we have parameters. A parameter is some&lt;br /&gt;
value you pass to the function in order for it to work. For example, in this&lt;br /&gt;
case, to square a number, we have to give it the number to square. Students&lt;br /&gt;
often ask: “What do we need to put as parameters? Do we even need any&lt;br /&gt;
parameters for this function?” There is a simple way to answer this question&lt;br /&gt;
for any function you write. Ask yourself this question: If you wanted some&lt;br /&gt;
person to do this task for you, would you need to give them anything? And,&lt;br /&gt;
if so, what? If you wanted a person to square a number for you, you would&lt;br /&gt;
have to give them that number. However, if you just wanted them to say&lt;br /&gt;
hello, you would not have to give them anything. Therefore, a function that&lt;br /&gt;
squares a number should take one parameter, and a function that displays&lt;br /&gt;
hello on the screen might not take any parameters. There will be a lot more&lt;br /&gt;
in-depth discussion on functions in Chapter 4.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-7935662400574941697?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/7935662400574941697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/function-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/7935662400574941697?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/7935662400574941697?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/function-basics.html' title='FUNCTION BASICS'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0MNQXo4fyp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-2504462236727709827</id><published>2011-08-04T08:24:00.001-07:00</published><updated>2011-08-04T08:24:50.437-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:24:50.437-07:00</app:edited><title>VARIABLE SCOPE</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;br /&gt;
In the beginning of this chapter, you were introduced to the concept of&lt;br /&gt;
variables. You saw the various data types, how to declare a variable, and&lt;br /&gt;
what proper names you could use for variables (as well as ones you&lt;br /&gt;
could not). There is one more topic concerning variables. This had to be&lt;br /&gt;
left until after the discussion about the structure of a C++ program, and&lt;br /&gt;
you will see why shortly. The topic at hand concerns WHERE you&lt;br /&gt;
declare a variable. This is called variable scope. Consider the following&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;
&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;example.&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int j;&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This variable is declared inside the main function. That means it is only&lt;br /&gt;
usable within that function. If you create other functions, they will not be&lt;br /&gt;
able to access the variable j. This is referred to as a local variable. A local&lt;br /&gt;
variable is a variable that is declared within a function, or within any&lt;br /&gt;
block of code. Now let’s look at another example.&lt;br /&gt;
int j;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
j++;&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
Notice that j was NOT declared inside the main function. It was&lt;br /&gt;
declared outside of any function. This means that it can be used&lt;br /&gt;
throughout your code. A variable declared outside of any function can be&lt;br /&gt;
used in any function, and is referred to as a global variable. This is referred&lt;br /&gt;
to as variable scope. Scope defines the range within which a variable can&lt;br /&gt;
be used. If the variable has local scope, then its range is restricted to the&lt;br /&gt;
function in which it was declared. It is essential to pay attention to the&lt;br /&gt;
scope of your variables. It is not uncommon for a beginner to declare a&lt;br /&gt;
variable inside one function, and then forget that it is only usable within&lt;br /&gt;
that function.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-2504462236727709827?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/2504462236727709827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/variable-scope.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/2504462236727709827?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/2504462236727709827?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/variable-scope.html' title='VARIABLE SCOPE'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0MEQn8-eip7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-8828632876186532542</id><published>2011-08-04T08:23:00.001-07:00</published><updated>2011-08-04T08:23:23.152-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:23:23.152-07:00</app:edited><title>COMPILING</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;br /&gt;
When you write a program you are typing in code. You might be simply&lt;br /&gt;
typing code into a basic text editor or into a commercial IDE (Integrated&lt;br /&gt;
Development Editor) such as Borland C++ Builder or Microsoft Visual&lt;br /&gt;
C++. But you will not be distributing what you are typing to end-users.&lt;br /&gt;
What do you distribute to them? First of all, what you type is the source&lt;br /&gt;
code. It is not an executable program. Remember that the source code is&lt;br /&gt;
simply all the programming commands that you write. The process of&lt;br /&gt;
taking your source code and creating an executable is called compiling.&lt;br /&gt;
The purpose of a compiler (whether it’s a command line compiler, or&lt;br /&gt;
one built into some commercial IDE) is to translate the specific programming&lt;br /&gt;
language code you wrote into standard machine instructions that&lt;br /&gt;
the computer can understand and run. That code is in a binary data file&lt;br /&gt;
(1’s and 0’s) that the machine can understand and execute (thus, the&lt;br /&gt;
term executable).&lt;br /&gt;
The specifics about how you compile a program depend on the compiler&lt;br /&gt;
you are using. Commercially available development kits such as&lt;br /&gt;
C++ Builder and Visual C++ usually have a button to press, or a dropdown&lt;br /&gt;
menu to select. Command line compilers require you to type in&lt;br /&gt;
compilation instructions at the command line. The specifics for using the&lt;br /&gt;
free Borland C++ compiler used in the examples in this book are given in&lt;br /&gt;
Appendix D.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-8828632876186532542?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/8828632876186532542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/compiling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/8828632876186532542?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/8828632876186532542?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/compiling.html' title='COMPILING'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0QHQn86eSp7ImA9WhdRFEo.&quot;'><id>tag:blogger.com,1999:blog-6641414276600510968.post-1214588849259033004</id><published>2011-08-04T08:22:00.001-07:00</published><updated>2011-08-04T08:22:13.111-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-04T08:22:13.111-07:00</app:edited><title>REVIEW QUESTIONS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
1. What is a variable?&lt;br /&gt;
2. What is a statement?&lt;br /&gt;
3. Which of the following are legal names for variables in C++?&lt;br /&gt;
a. firstname&lt;br /&gt;
b. &amp;amp;salary&lt;br /&gt;
c. x&lt;br /&gt;
d. y&lt;br /&gt;
e. first@name&lt;br /&gt;
4. All valid C++ statements end with a what?&lt;br /&gt;
5. What type of value must the main function return?&lt;br /&gt;
6. What is the purpose of brackets?&lt;br /&gt;
7. What is a local variable?&lt;br /&gt;
8. What is a global variable?&lt;br /&gt;
9. If a function does not return anything, then what do you put for its&lt;br /&gt;
return type?&lt;br /&gt;
10. What is a parameter?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6641414276600510968-1214588849259033004?l=learn2pgms.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learn2pgms.blogspot.com/feeds/1214588849259033004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/review-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/1214588849259033004?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6641414276600510968/posts/default/1214588849259033004?v=2'/><link rel='alternate' type='text/html' href='http://learn2pgms.blogspot.com/2011/08/review-questions.html' title='REVIEW QUESTIONS'/><author><name>Deepak.C</name><uri>http://www.blogger.com/profile/00546223358512516263</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry></feed>