Directory: Listings | Search | New | Top | Popular | Random | Suggest | Categories Map | Articles COmail

Programming?

Are you currently learning to program in C++ or JAVA? Check out the members area for beginners, intermediate, or advanced. Also, there is source code posted throughout the rest of this website, check the pages for the respected language.

Forum Area maSpinner

For current and active topics check here: Active Topics.
Become a member, it's free, registration is here: Registration.
For a live feed that is parsed into an HTML page: New Posts (HTML)
For a live feed that you can save in your browser: New Posts (RSS)

Other C++ source code examples - Check the C++ source code examples page for: for loops, while loops, <fstream> (inFile and outFile), arrays, switch control structures, if, else if, else statements, functions(), and more. Also, other language source code will be uploaded including JAVA application examples.

Source Code - Programs

In computer science, source code is any collection of statements or declarations written in some human-readable computer programming language. Source code is the means most often used by programmers to specify the actions to be performed by a computer. Source code can also be a working program.

C++ Program: While loop counter

Compiler (Visual Studio) showing C++ Source Code:
// While loop.
#include <iostream>
using namespace std;
int main()
{
   int num = 1;  // Initialize counter starting at 1.

   while (num <= 7) // Loop - number controls how many times.
   {
	 cout << num;  // Show the number as it increments.
   	 num++;  // Increment by adding 1 each iteration.
   	 cout << " - Hello world!\n";
   }
   cout << "\n";
   return 0;
}
/*==================[output]===============================
1 - Hello world!
2 - Hello world!
3 - Hello world!
4 - Hello world!
5 - Hello world!
6 - Hello world!
7 - Hello world!

Press any key to continue . . .
===========================================================*/
The above source code is C++, using a while loop.
Here is the Source Code: while loop

Debugging Source Code

Debugging is a very important task in the software development process, because an incorrect program can have significant consequences for its users. Some languages are more prone to some kinds of faults because their specification does not require compilers to perform as much checking as other languages. Use of a static analysis tool can help detect some possible problems. Debugging is often done with IDEs like Visual Studio (Microsoft), NetBeans, and Eclipse. Standalone debuggers like GDB are also used, and these often provide less of a visual environment, usually using a command line.


Computer Programming

Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language. The code may be a modification of an existing source or something completely new. The purpose of programming is to create a program that exhibits a certain desired behavior (customization). The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.


Source Code style and visual appearance

The issues usually considered as part of programming style include the layout of the source code, including indentation, the use of white space around operators and keywords, the style and spelling of user-defined identifiers, variable names, and the use of comments.

Source code quality

Coding style:
A computer has no concept of "well-written" source code. However, from a human point of view source code can be written in a way that has an effect on the effort needed to comprehend its behavior. Many source code programming style guides, which often stress readability and usually language-specific conventions are aimed at reducing the cost of source code maintenance.

Understandability

Are variable names descriptive of the physical or functional property represented? Do uniquely recognizable functions contain adequate comments so that their purpose is clear? Are deviations from forward logical flow adequately commented? Are all elements of an array functionally related?

Source Code VS. ambiguous?

Thousands of different programming languages have been created, mainly in the computing field. Programming languages differ from most other forms of human expression in that they require a greater degree of precision and completeness. When using a natural language to communicate with other people, human authors and speakers can be ambiguous and make small errors, and still expect their intent to be understood. However, figuratively speaking, computers "do exactly what they are told to do", and cannot "understand" what code the programmer intended to write. The combination of the language definition, a program, and the program's inputs must fully specify the external behavior that occurs when the program is executed, within the domain of control of that program.

Which language is most widely used?

Combining and averaging information from various Internet sites, langpop.com claims that in 2008 the 10 most cited programming languages are (alphabetical order): C, C++, C#, Java, JavaScript, Perl, PHP, Python, Ruby, and SQL.

Source Code
Languages:

  • C++
  • JAVA
  • Visual Basic
  • JavaScript
  • CSS
  • HTML

System
Development

Methods:
  • Structured Analysis
  • Object-Oriented
  • Waterfall
  • Agile
  • Spiral

Structured or O-O?


Before 1940

The first programming languages predate the modern computer. At first, the languages were codes. The Jacquard loom, invented in 1801, used holes in punched cards to represent sewing loom arm movements in order to generate decorative patterns automatically. During a nine-month period in 1842-1843, Ada Lovelace translated the memoir of Italian mathematician Luigi Menabrea about Charles Babbage's newest proposed machine, the Analytical Engine. With the article, she appended a set of notes which specified in complete detail a method for calculating Bernoulli numbers with the Engine, recognized by some historians as the world's first computer program.

Programming Languages by year

  • 1943 - Plankalkul (Konrad Zuse)
  • 1943 - ENIAC coding system
  • 1949 - C-10
  • 1951 - Regional Assembly Language
  • 1952 - Autocode
  • 1954 - FORTRAN
  • 1954 - IPL (forerunner to LISP)
  • 1955 - FLOW-MATIC (forerunner to COBOL)
  • 1957 - COMTRAN (forerunner to COBOL)
  • 1958 - LISP
  • 1958 - ALGOL 58
  • 1959 - FACT (forerunner to COBOL)
  • 1959 - COBOL
  • 1962 - APL
  • 1962 - Simula
  • 1962 - SNOBOL
  • 1963 - CPL (forerunner to C)
  • 1964 - BASIC
  • 1964 - PL/I
  • 1967 - BCPL (forerunner to C)
  • 1968 - Logo
  • 1970 - Pascal
  • 1970 - Forth
  • 1972 - C
  • 1972 - Smalltalk
  • 1972 - Prolog
  • 1973 - ML
  • 1975 - Scheme
  • 1978 - SQL (initially only a query language, later extended with programming constructs)
  • 1980 - C++ (as C with classes)
  • 1983 - Ada
  • 1984 - Common Lisp
  • 1985 - Eiffel
  • 1986 - Erlang
  • 1987 - Perl
  • 1988 - Tcl
  • 1989 - FL (Backus)
  • 1990 - Haskell
  • 1991 - Python
  • 1991 - Java
  • 1993 - Ruby
  • 1993 - Lua
  • 1994 - CLOS (part of ANSI Common Lisp)
  • 1995 - Delphi (Object Pascal)
  • 1995 - JavaScript
  • 1995 - PHP
  • 1997 - Rebol
  • 2001 - C#
  • 2001 - Visual Basic .NET
  • 2002 - F#
  • 2003 - Scala
  • 2003 - Factor
  • 2006 - Windows Power Shell
  • 2007 - Clojure
  • 2007 - Groovy
  • 2009 - Go

JAVA VS. C++

How similar are they?

Similarities and Differences


Visual Basic

Easier or harder than C++?



C++

  • Variables
  • strings
  • Arrays
  • Functions
  • Return values
  • While loop
  • Do-while
  • For loops

Source Code


Programming Languages

A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human communication. Many programming languages have some form of written specification of their syntax (form) and semantics (meaning). Some languages are defined by a specification document. For example, the C programming language is specified by an ISO Standard. Other languages, such as Perl, have a dominant implementation that is used as a reference. The earliest programming languages predate the invention of the computer, and were used to direct the behavior of machines such as Jacquard looms and player pianos. Thousands of different programming languages have been created, mainly in the computer field, with many more being created every year. Most programming languages describe computation in an imperative style, i.e., as a sequence of commands, although some languages, such as those that support functional programming or logic programming, use alternative forms of description.

Programming

The history of computer programming language development can often be best understood in the light of attempts to master the complexity of computer programs, which otherwise becomes more difficult to understand in proportion (perhaps exponentially) to the size of the programs. (Another way of looking at the evolution of programming languages is simply as a way of getting the computer to do more and more of the work, but this may be a different way of saying the same thing.) Lack of understanding of a program's overall structure and functionality is a sure way to fail to detect errors in the program, and thus the use of better languages should, conversely, reduce the number of errors by enabling a better understanding.

Syntax

In linguistics, syntax (from Ancient Greek) is the study of the principles and rules for constructing sentences in natural languages. In addition to referring to the discipline, the term syntax is also used to refer directly to the rules and principles that govern the sentence structure of any individual language, as in "The syntax of Modern Irish." Modern research in syntax attempts to describe languages in terms of such rules. Many professionals in this discipline attempt to find general rules that apply to all natural languages. The term syntax is also sometimes used to refer to the rules governing the behavior of mathematical systems, such as logic, artificial formal languages, and computer programming languages.