0% found this document useful (0 votes)
47 views5 pages

Compiler Based: Example HTML

The document discusses key concepts in C++ programming including that C++ is a compiler-based, strongly typed language that uses pointers for efficient memory access. It provides an example Hello World program and explains how to write, compile, and run a basic C++ program. It also lists some common C++ data types and defines global variables and expressions.

Uploaded by

Indhu Mcamphil
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)
47 views5 pages

Compiler Based: Example HTML

The document discusses key concepts in C++ programming including that C++ is a compiler-based, strongly typed language that uses pointers for efficient memory access. It provides an example Hello World program and explains how to write, compile, and run a basic C++ program. It also lists some common C++ data types and defines global variables and expressions.

Uploaded by

Indhu Mcamphil
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/ 5

Compiler based

C++ is a compiler based programming language that means without


compilation no C++ program can be executed. First we need compiler to
compile our program and then execute.
Syntax based language
C++ is a strongly tight syntax based programming language. If any
language follow rules and regulation very strictly known as strongly tight
syntax based language. Example C, C++, Java, .net etc. If any language not
follow rules and regulation very strictly known as loosely tight syntax based
language.
Example HTML.
Efficient use of pointers
Pointers is a variable which hold the address of another variable, pointer
directly direct access to memory address of any variable due to this performance
of application is improve. In C++ language also concept of pointer are available.
Advantage of C++ Programming Language
 Abstract data type defining is very good
 C++ language is efficient having less compiled time.
 It is much suitable for large projects.
 Encapsulation, polymorphism, abstraction are the important properties of
C++ language
 Objects, methods, instance, message passing, inheritance are some
important properties inherited by this language
Getting started with C++
Write a C++ program
Now that have a compiler installed, its time to write a C++ program.
Let's start with the epitome of programming example's, it, the Hello world
program. We'll print hello world to the screen using C++ in this example. Create
a new file called hello.cpp and write the following code to it:
#include<iostream>
int main() {
std::cout << "Hello World\n";
}
Line 1: We start with the #include<iostream> line which essentially tells the
compiler to copy the code from the iostream file(used for managing input and
output streams) and paste it in our source file. Header iostream, that allows to
perform standard input and output operations, such as writing the output of this
program (Hello World) to the screen. Lines beginning with a hash sign (#) are
directives read and interpreted by what is known as the preprocessor.

Line 2: A blank line: Blank lines have no effect on a program.

Line 3: We then declare a function called main with the return type of int.
main() is the entry point of our program. Whenever we run a C++ program, we
start with the main function and begin execution from the first line within this
function and keep executing each line till we reach the end. We start a block
using the curly brace({) here. This marks the beginning of main's function
definition, and the closing brace (}) at line 5, marks its end. All statements
between these braces are the function's body that defines what happens when
main is called.

Line 4:
std::cout << "Hello World\n";
This line is a C++ statement. This statement has three parts: First, std::cout,
which identifies the standard console output device. Second the insertion
operator << which indicates that what follows is inserted into std:: cout. Last,
we have a sentence within quotes that we'd like printed on the screen. This will
become more clear to as we proceed in learning C++.

In short, we provide a cout object with a string "Hello world\n" to be printed to


the standard output device.
Note that the statement ends with a semicolon (;). This character marks
the end of the statement
Compile the Program
Now that we've written the program, we need to translate it to a language that
the processor understands, ie, in binary machine code. We do this using a
compiler we installed in the first step. need to open r terminal/cmd and navigate
to the location of the hello.cpp file using the cd command. Assuming installed
the GCC, can use the following command to compile the program:
$ g++ -o hello hello.cpp
This command means that want the g++ compiler to create an output file, hello
using the source file hello.cpp.
Run the program
Now that we've written our program and compiled it, time to run it! can run the
program using:
$ ./hello
will get the output:
Hello world

Data Types in C++


 char: For characters. Size 1 byte.
 int: For integers. Size 2 bytes.
 float: For single precision floating point. Size 4 bytes.
 double: For double precision floating point. Size 8 bytes.
 bool: For booleans, true or false.
 wchar_t: Wide Character.

What are global variables in C++?


Global Variable in C++with
Example. ...Variable Scope in C+
+Inside a function or a block which is
called local variables, The variables
which are declared outside of all the
function and accessible from all
functions including main function are
known as Global variables.
What is a expression in C++?
"Expression in C++is form
when we combine operands (variables
and constant) and C++OPERATORS.
"Expression can also be defined as: ...
OPERANDS INC++PROGRAM are
those values on which we want to
perform perform operation. There are
three types ofexpressions:
Arithmeticexpression
EXPRESSION IN C++
"Expression in C++ is form when we combine operands (variables and
constant) and C++ OPERATORS. "Expression can also be defined as:
"Expression in C++ is a combination of Operands and Operators."
OPERANDS IN C++ PROGRAM are those values on which we want to
performoperation.
There are three types of expressions:
1. Arithmetic expression
2. Relational expression
3. Logical expression

You might also like