- C++ Programming Basics
- C++ Tutorial
- C++ Environment Setup
- C++ Character Set
- C++ Keywords
- C++ Identifiers
- C++ Constants
- C++ Punctuators
- C++ Program Structure
- C++ Basic Syntax
- C++ Comments
- C++ Basic Programs
- C++ Input Output Operator
- C++ Input Output Stream
- C++ Type & Variable
- C++ Data Types
- C++ Data Type Modifiers
- C++ Variables
- C++ Variable Types
- C++ Variable Scope
- C++ Storage Classes
- C++ Formatting Output
- C++ Operators
- C++ Operators
- C++ Type Conversion
- C++ Numbers
- C++ Assignment Operator
- C++ Shorthand
- C++ Flow of Control
- C++ Statements
- C++ Flow Control
- C++ Decision Making
- C++ if if-else if-else-if switch
- C++ Loops
- C++ for while do-while Loop
- C++ break continue goto
- C++ Standard Library
- C++ Standard Library
- C++ Header Files
- C++ Character String
- C++ Mathematical Functions
- C++ Functions
- C++ Functions
- C++ Function Types
- C++ Function Prototype
- C++ Function Call
- C++ Function Return
- C++ Friend Function
- C++ Scope Rules
- C++ Arrays & Strings
- C++ Arrays
- C++ One Dimensional Arrays
- C++ Two Dimensional Arrays
- C++ Strings
- C++ Data Structure
- C++ Data Structure
- C++ Access Structure Member
- C++ Nested Data Structure
- C++ Structure Array
- C++ Pass Structure to Function
- C++ typedef
- C++ #define
- C++ Programming Pointers
- C++ Pointers
- C++ Memory Map
- C++ Free Store
- C++ Declare Initialize Pointers
- C++ Dynamic Memory Allocation
- C++ Pointers & Arrays
- C++ Pointers & Const
- C++ Pointers & Functions
- C++ Pointers & Structures
- C++ Objects as Function Arguments
- C++ Pointers & Objects
- C++ References
- C++ File Handling
- C++ File Handling
- C++ File Streams
- C++ Data Files
- C++ Opening & Closing Files
- C++ Steps to Process Files
- C++ Change Stream Behaviour
- C++ Sequential I/O Operations
- C++ Detecting EOF
- C++ File Pointers Random Access
- C++ Binary Files Operations
- C++ Error Handling
- C++ Object Oriented
- C++ Object Oriented
- C++ Function Overloading
- C++ Classes & Objects
- C++ Constructors & Destructors
- C++ Inheritance
- C++ Encapsulation
- C++ Polymorphism
- C++ Data Abstraction
- C++ Interfaces
- C++ Programming Advance
- C++ Linked Lists
- C++ Stacks
- C++ Queues
- C++ Date Time
- C++ Preprocessors
- C++ Exception Handling
- C++ Namespaces
- C++ Dynamic Memory
- C++ Multithreading
- C++ Templates
- C++ Signal Handling
- C++ Web Programming
- C++ Programming Examples
- C++ Programming Examples
- C++ Programming Test
- C++ Programming Test
- Give Online Test
- All Test List
C++ Statements
Statements are the instructions gives to the computer to perform any kind of action, be it data movements, be it making decisions or be it repeating actions. Statements from the smallest executable unit within C++ program.
Statements are terminated with a semicolon (;). The simplest statement is empty, or null statement. It takes the following form :
; // it is a null statement (notice, it is just a semicolon)
A null statement is useful in those instances where the syntax of the language requires the presence of a statement but where the logic of the program does not.
Compound Statement - Block Statement
A compound statement in C++ is a sequence of statements enclosed by a pair of braces {}. For example,
{ statement1 ; statement2 ; : : : statementN ; }
Represents a compound statement. A compound statement is equivalently called a block. A compound statement or a block is treated as a single unit and may appear anywhere in the program where a single statement may appear. Let's take an example
/* C++ Statements */ #include<iostream.h> #include<conio.h> #include<stdlib.h> void main() { clrscr(); int a, b, sum; cout<<"Enter any two numbers: "; cin>>a>>b; sum = a + b; cout<<"Sum = "<<sum; char ch; cout<<"\n\nWant to see all the statements used ? (y/n).."; cin>>ch; cout<<"\n"; if(ch=='y' || ch=='Y') { cout<<"These are the statements used to perform addition:\n\n"; cout<<"int a, b, sum;\n"; cout<<"cout<<\"Enter any two numbers: \";\n"; cout<<"cin>>a>>b;\n"; cout<<"sum = a + b;\n"; cout<<"cout<<\"Sum = \"<<sum;\n"; } else { cout<<"Press any key to exit..\n"; getch(); exit(1); } getch(); }
Here is the sample run of the above C++ program:

More Examples
Below are some more C++ programs listed, that you may like:
- Add two Numbers
- Fahrenheit to Centigrade Conversion
- Centigrade to Fahrenheit Conversion
- Print ASCII Values
- Print Fibonacci Series
- Check Palindrome or Not
- Check Armstrong or Not
- Generate Armstrong Numbers
- Find ncR nPr
« Previous Tutorial Next Tutorial »
Like/Share Us on Facebook 😋