• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C++ » Structures » What is Control Statements? Explain
Next →
← Prev

What is Control Statements? Explain

By Dinesh Thakur

We know that Instruction those are written in c++ Language are Executed in Sequence wise or Step Wise as they are Written in Program. Or these are executed in Sequence Order.Decision Making statements are used when we wants to execute the statements as according to the user needs. A User can Change the Sequence of the Statements for Execution.

 Many Times we Wants to Execute the Set of Instructions to be executed in one Situation and other Statements in other Situations for Executing the Statements in Specific Situation there are Some Decision Making Statements or Decision Control Statements those are provided by the C++ Language. In The Decision First a Condition is checked it is true then it Executes the next Instruction otherwise it Executes other Statements.

 

 There are three decision making statements :-

 

1) if

 2) if-else

3) The Conditional Operators.

 

Understanding If statement

 

The Keyword if tells the compiler what follows The Condition Following the Keyword if is always enclosed within a pair or Parentheses if The Condition id True Then the Statements is Executed if the Condition is not true then the Statement is not Executed For Checking a condition. Relational Operators are Used Like > ,< ,==, >=,<= etc. The if statement is widely used for checking a particular condition

Suppose you want to check the condition and then execute the condition

if your condition is met

for ex:

          if(a>b)

          then print a is greater then here we first check the condition

          that either a is greater than b if yes then execute the condition

 

1) if-else= the if Statement is used for Executing a Single Statement or a Group of Statements When the Condition Following is true. It does nothing when the Condition is False , For Executing the group of Statements either a Condition is False we uses else The if-else is similar to if but the difference is that is also provides us the alternative to execute the other statement if a condition is not true for ex:

          if(a>b)

                         cout <<a

          else

                         cout <<b

Here if first checks the condition either the a is greater than b if yes then it will print a suppose if a is not greater than b then it will be print b because we specify the b in the else statement.

 

2) if-elseif

The if-elseif is similar to the if-else but here the first if is used for checking a condition and the other elseif is used for checking a one more condition suppose if we wants to check the two or more conditions then we can use the if-elseif In This first if Statement Checks the Condition whether it is true or not if the first Condition is false then it jumps to the Second if Statement for Checking the next Condition so and so. if all the Conditions are false the Control will jump to the else block

 

3) Conditional Operator: – This Operates is also same like a if –else Statement., In this we first Checks the Condition and then this will gives us the Result after Checking the Condition. This Operators uses ? and : Signs . In this ? is used for Checking a Condition after Checking this will gives us the Results but if a Condition has Failed then this will Execute the Statements those are Written in the : ( Colon ) For Example

                         int a,b,c

                                      a=10

                                      b=20

                                      c= (a>b) ? a : b

                             Now here we are seeing that the value f a is Less than so this will Store the value of b variable into the C variable. Means c Contains 20.

 

Switch Statement:-This Statement is Similar to if –else but it uses matching operations rather than checking a condition if we Wants to Check Many Conditions then the Program will very Complex So in that Situation We Will use Switch Statement Switch Statement Uses Many Cases rather and it matches the value with Case where it Matches it will Execute the Statement But There is Very Necessary to Stop the Execution of Each Case So that it Doesn’t Execute Next Case So that for this Purpose we have to put the break Statement after Ending of an Each Case We Know if uses Else Statement if Condition is False or All Conditions are False The Code of Else Statement is Executed if Code of all if statements is false So that in Switch Default is used when all Cases are not Matched.

 

You’ll also like:

  1. What is Control Statements?Explain
  2. Explain control statements those are used in C programming language
  3. Conditional Statements in C++ or if Statements
  4. Iteration Statements or Loops in C++
  5. Jump Statements in c++ or Goto statement
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C++ Tutorials

C++ Tutorials

  • C++ - Data Types
  • C++ - Operators Types
  • C++ - CPP Program Structure
  • C++ - Conditional Statements
  • C++ - Loop
  • C++ - do-While Loop
  • C++ - Control Statements
  • C++ - Tokens
  • C++ - Jump Statements
  • C++ - Expressions
  • C++ - Constants
  • C++ - Character Set
  • C++ - Iteration Statements
  • C++ - I/O Statements
  • C++ - String
  • C++ - Manipulators

C++ Operator

  • C++ - Input/Output Operator
  • C++ - Operator Overloading

C++ Functions

  • C++ - Functions
  • C++ - Member Functions
  • C++ - Returning Object from Function
  • C++ - Call by Value Vs Reference
  • C++ - Friend Function
  • C++ - Virtual Function
  • C++ - Inline Function
  • C++ - Static Data Members
  • C++ - Static Member Functions

C++ Array & Pointer

  • C++ - Array
  • C++ - Array of Objects
  • C++ - Arrays as Class Members
  • C++ - Vector
  • C++ - Pointer
  • C++ - 'this' Pointer

C++ Classes & Objects

  • C++ - Class
  • C++ - Program Structure With Classes
  • C++ - OOP’s
  • C++ - Objects as Function Arguments
  • C++ - Procedure Vs OOL
  • C++ - Object Vs Class
  • C++ - Creating Objects
  • C++ - Constructors
  • C++ - Copy Constructor
  • C++ - Constructor Overloading
  • C++ - Destructor
  • C++ - Polymorphism
  • C++ - Virtual Base Class
  • C++ - Encapsulation

C++ Inheritance

  • C++ - Inheritance
  • C++ - Multiple Inheritance
  • C++ - Hybrid Inheritance
  • C++ - Abstraction
  • C++ - Overloading

C++ Exception Handling

  • C++ - Exception Handling
  • C++ - Templates
  • C++ - Standard Template Library

C++ Data Structure

  • C++ - Link List

C++ Programs

  • C++ Program for Electricity Bill
  • C++ Program for Multiply Matrices
  • C++ Program for Arithmetic Operators
  • C++ Program For Matrices
  • C++ Program for Constructor
  • C++ Program Verify Number
  • C++ Program Array Of Structure
  • C++ Program to find Average Marks
  • C++ Program Add And Subtract Matrices
  • C++ Program Menu Driven
  • C++ Program To Simple Interest
  • C++ Program To Find Average
  • C++ program exit()
  • C++ Program Using Array Of Objects
  • C++ Program Private Member Function
  • C++ Program To Reverse A String
  • C++ Program to Operator Overloading

Other Links

  • C++ - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW