Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Variables. Data Types

Posted: Oct/07/2009   By: pankaj   Points:15   Category: C/C++/VC++  - C++    Views:132   Vote Up (0)   Vote Down (0)    
The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting program just to obtain a simple sentence written on the screen as result. It certainly would have been much faster to type the output sentence by ourselves. However, programming is not limited only to printing simple texts on the screen. In order to go a little further on and to become able to write programs that perform useful tasks that really save us work we need to introduce the concept of variable.

Let us think that I ask you to retain the number 5 in your mental memory, and then I ask you to memorize also the number 2 at the same time. You have just stored two different values in your memory. Now, if I ask you to add 1 to the first number I said, you should be retaining the numbers 6 (that is 5+1) and 2 in your memory. Values that we could now for example subtract and obtain 4 as result.

The whole process that you have just done with your mental memory is a simile of what a computer can do with two variables. The same process can be expressed in C++ with the following instruction set:

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

Data Structures Tutorial

  
We have already learned how groups of sequential data can be used in C++. But this is somewhat restrictive, since in many occasions what we want to store are not mere sequences of elements all of the same data type, but sets of different elements with different data types.

Data structures

A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Data structures are declared in C++ using the following syntax:

struct structure_name {
member_type1 member_name1;
member_type2 member_name2;
member_type3 member_name3;
.
.
} object_names;

Scope of Variables in Function in C++

  
In this C++ Tutorial you will learn about Scope of Variables in Function viz Local Variables - Scope of Local Variables, Global Variables - Scope of Global Variables.

C++ Function Passing Types

  
In this C++ tutorial, you will learn about function passing types, two types of arguments passing in functions - passed by value and passed by reference are discussed here.
 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge