Sep 4, 2013

Simple program in C++

Unknown | 2:20 PM |
Today I am going to tell you how to create a simple C++ program.

Suppose we would like to display the message “Hello world! This is my first program” on your video screen.

#include <iostream. h>
void main()  // program heading
  {  //  begin
     cout  << "Hello world! This is my first program";
  }  //  end

The function main() must be placed before the begin statement. It invokes another function to perform its job. The { symbol or notation is used as the begin statement. The declaration of variables and the type of operations are placed after the begin statement. The end statement is denoted by the symbol  }. In C++ , the semicolon (;) serves the purpose of the statement terminator rather than a separator.

 Statements are terminated by a semicolon and are grouped within braces {….}. Most statement contains expression, sequences of operators, function calls, variables and constants that specify computation.

Variable and function names are of arbitrary length and consist of upper and lower case letters, digits and underscore and they may not start with a numeral. All C++ keywords are written in lowercase letters.
Any statement or functions within comments are not executable and they are ignored by the compiler.

No comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Search