0% found this document useful (0 votes)
30 views7 pages

Sample C++ Program: Simula

C++ development began in 1979 when Bjarne Stroustrup worked on adding object-oriented programming features to C while completing his PhD thesis. Some key additions to C included classes, inheritance, and function overloading. There are multiple versions of C++ including Visual C++, Borland C++, and standard ANSI C++. A basic C++ program structure includes header files, global declarations, class declarations, the main function, and method definitions. C++ supports both structured and object-oriented programming paradigms.

Uploaded by

Javer Borngo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

Sample C++ Program: Simula

C++ development began in 1979 when Bjarne Stroustrup worked on adding object-oriented programming features to C while completing his PhD thesis. Some key additions to C included classes, inheritance, and function overloading. There are multiple versions of C++ including Visual C++, Borland C++, and standard ANSI C++. A basic C++ program structure includes header files, global declarations, class declarations, the main function, and method definitions. C++ supports both structured and object-oriented programming paradigms.

Uploaded by

Javer Borngo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

C++

HISTORY

1. C++ Development started in 1979.


2. During the creation of Ph.D. thesis, Bjarne Stroustrup worked with language called Simula.
3. Simula is basically useful for the simulation work.
4. Simula was first language to support object-oriented programming paradigm
5. Bjarne Stroustrup identified that this OOP features can be included in the software
development.
6. After that Bjarne Stroustrup started working on the C language and added more extra OOP
features to the classic C.
7. He added features in such a fashion that the basic flavour of C remains unaffected.
8. C++ includes some add-on features such as classes, basic inheritance, in-lining, default
function arguments, and strong type checking

C++ supports for the Structured programming and also it fully supports OOP

1. Encapsulation
2. Data hiding
3. Inheritance
4. Polymorphism.

There are several versions of C++ Programming Language –

1. Visual C++
2. Borland C++
3. Turbo C++ (To Read more click here)
4. Standardize C++ [ANSI C++]

Sample C++ Program


/*
This is a simple C++ program.
Call this file Sample.cpp.
*/

#include <iostream>
using namespace std;

// A C++ program begins at main().


int main()
{
cout << "C++ is power programming.";
return 0;
}
C++ is power programming.
Explanation : First C++ Program
Consider the following line in the programs –
/*
This is a simple C++ program.
Call this file Sample.cpp.
*/

1. It is Comment in C++ Language which is ignored by compiler


2. Comments are written for user understanding.
#include <iostream>

3. C++ uses different header files like C.


4. Include statement tells compiler to include Standard Input Output Stream inside C++ program.
5. This header is provided to user along with the compiler.
int main()

6. Each C++ program starts with the main function like C Programming.
7. Return type of the C++ main function is integer, whenever main function returns 0 value to
operating system then program termination can be considered as smooth or proper.
8. Whenever some error or exception occurs in the program then main function will return the
non zero value to operating system.
cout << "C++ is power programming.";

9. C++ Insertion operator (<<) is used to display value to the user on the console screen.

return 0;

10. return statement sends status report to the operating system about program execution whether
program execution is proper or illegal.
C++ Compilers : 5 most popular C++ IDE / Compiler used to Run C++
Program
C++ Compilers are OS dependent so writing complex C++ Program is not an easy task , we have to
put lot of efforts to write C++ Program if we don’t have IDE. IDE makes our task easy. We have list
of different compilers used to compile and execute C++ programs on the different Operating
Systems (OS). We have summarized all the compiles in the below list –

1. Borland C++ / Turbo C++ [Old and most popular IDE]


2. Visual C++ [Microsoft Platform]
3. Dev C++
4. GCC
5. Eclipse

Structure of C++ Program : Layout of C++ Program


C++ Programming language is most popular language after C Programming language. C++ is first
Object oriented programming language.We have summarize structure of C++ Program in the following

Section 1 : Header File Declaration Section


1. Header files used in the program are listed here.
2. Header File provides Prototype declaration for different library functions.
3. We can also include user define header file.
4. Basically all preprocessor directives are written in this section.

Section 2 : Global Declaration Section


1. Global Variables are declared here.
2. Global Declaration may include –
o Declaring Structure
o Declaring Class
o Declaring Variable

Section 3 : Class Declaration Section


1. Actually this section can be considered as sub section for the global declaration section.
2. Class declaration and all methods of that class are defined here.

Section 4 : Main Function


1. Each and every C++ program always starts with main function.
2. This is entry point for all the function. Each and every method is called indirectly through main.
3. We can create class objects in the main.
4. Operating system call this function automatically.

Section 5 : Method Definition Section


1. This is optional section . Generally this method was used in C Programming.

C++ Provides huge Function Library that’s why its popularity is increasing day by day and more
programmers are inclining towards C++ due to its multiple features –

1. C++ is an Object Oriented Programming Language (OOPL).


2. C++ have huge Function Library
3. C++ is highly Flexible language with Versatility.
4. C++ can be used for developing System Software viz., operating systems, compilers, editors
and data bases.
5. C++ is suitable for Development of Reusable Software. , thus reduces cost of software
development.
6. C++ is a Machine Independent Language.

VARIABLE NAMING

What is Identifier ?
Any used defined name given to the program element is called as identifier. (i.e Program elements
are identified by program with the identifier name)

Some Facts About Identifier :

1. It is name given to program element.


2. Identifier are the names is given by the programmer.
3. An identifier is used for any variable, function, data definition etc.
4. We can give any valid name to the identifier.

The rules in C++ for identifiers are :

1. Only Alphabets,Digits and Underscores are permitted.


2. Identifier name cannot start with a digit.
3. Key words cannot be used as a name.
4. Upper case and lower case letters are distinct.
5. Special Characters are not allowed
6. Global Identifier cannot be used as “Identifier”.

Sample Examples of C++ Identifier :


In the C++ programming language, an identifier is a combination of alphanumeric characters, the
first being a letter of the alphabet or an underline, and the remaining being any letter of the
alphabet, any numeric digit, or the underline.
Valid Examples are :
Identifier Note

Name Capital Letter and Small Letters are Allowed

name Small Letters are allowed

name_1 Digits and Underscore is allowed along with alphabets

Keywords are allowed but we have to change case of any


Int
letter or complete word

Keywords are allowed but we have to change case of any


INT
letter or complete word

_SUM Underscore at the first position is allowed in C++ language

sum_of_the_numbers We can concatenate multiple words with underscore

Best Style to concatenate multiple words (Changing case of


firstName
First Letter of Successive Word)

Identifier We can give concept name as Identifier name

As we are not going to include stdio.h header file we can use


printf
printf as identifier.
HISTORY
SAMPLE PROGRAM WITH EXPLANATION
COMPILERS AND IDE
PROGRAM STRUCTRURE
COMMENTS
CIN
COUT
VARIABLE DECLARATION
DATA TYPES
OPERATORS
ASSIGNMENT
COMPOUND ASSIGNMENT
INC
DEC
RELATIONAL COMPARISON
LOGICAL
CONSTANTS
CHARACTERS
STRINGS

You might also like