2 Answers - Sort by: Date | Rating
If statement is used for a decision on the given expression, if the given expression is true then the statement in "if" statement body will execute otherwise not. If statement is often used with else, and called "if else". If the expression is true then the body of "if" will execute other wise the body of "else" will execute.
The example of "if" statement
if(a == 10)
{
cout<<"Hello";
}
And the structure of if-else statement
if(a == 10)
{
cout<<"Hello! How are you?";
}
else
{
cout<<"Hi! I am fine.";
}
The example of "if" statement
if(a == 10)
{
cout<<"Hello";
}
And the structure of if-else statement
if(a == 10)
{
cout<<"Hello! How are you?";
}
else
{
cout<<"Hi! I am fine.";
}
0
0
The "if statement" is used to execute (or ignore) a set of statements after testing a condition.
The "if statement" evaluates a condition. If the given condition is true, the statement ( or a set of statements) following the "if statement" is executed. If the given condition is false, the statement ( or set of statements) following the "if statement" condition is ignored and the control transfer to the next statement.
The syntax of the "if statement" is:
If 9condition)
Statements-1;
Statement-2;
Condition: specifies a condition or a relational expression. When this condition is true, the statement following the "if statement" is executed. If the given condition is false, the statement following the "if statement" is ignored and the control transfers to the next statement.
In the above syntax, only statement –1 will be executed if the given condition is true otherwise the control shifts to Statement-2 that comes after the Statement-1.
To execute a set of statements following the "if statements", the set of statements is enclosed in curly braces, i.e. within {}. The statements in braces are also known as compound statements.
If (condition)
{
Statement-1
Statement-2
Statement-3
Statement-m
}
Statement-n
The "if statement" evaluates a condition. If the given condition is true, the statement ( or a set of statements) following the "if statement" is executed. If the given condition is false, the statement ( or set of statements) following the "if statement" condition is ignored and the control transfer to the next statement.
The syntax of the "if statement" is:
If 9condition)
Statements-1;
Statement-2;
Condition: specifies a condition or a relational expression. When this condition is true, the statement following the "if statement" is executed. If the given condition is false, the statement following the "if statement" is ignored and the control transfers to the next statement.
In the above syntax, only statement –1 will be executed if the given condition is true otherwise the control shifts to Statement-2 that comes after the Statement-1.
To execute a set of statements following the "if statements", the set of statements is enclosed in curly braces, i.e. within {}. The statements in braces are also known as compound statements.
If (condition)
{
Statement-1
Statement-2
Statement-3
Statement-m
}
Statement-n
0
0
Nice answer
- What Is The Types Of Datawares?
- Is Each Serial ATA Connector And Cable Is Dedicated To A Single Drive?
- The Hard Drive Controller Is ____ On A Circuit Board On Or Inside The Drive Housing?
- For Today's Hard Drives, The Hard Drive Controller Is ____ On A Circuit Board On Or Inside The Drive Housing?
- Can A Parallel ATA Connector Can Accommodate One Data Cable For Two Drives?
- Who Have Made The Keyboard Of Computer?
- Why Should Be A Network Security Policy In Networked Companies?
- Find Out The Different Operating System For Super Computer,main Frame Computer, Server Machine, Micro Computer, Pen Based Computer?
- Where Can I Get Free Digital Signature?
- What Are The Problems Involving Mining?
- What Are The 2 Marks In Stack And Queue?
- What Is Pds In Computer?
- I Have A Virus On My Computer And Its Blocking Every Attempt I Make. How To I Access The Start Up Directory For Windows XP?
- How Do I Take Off The Keys On My Hp Laptop?
- Can Someone Pls Explain The Color Coding In The Cat 5 Network Cable?
- What Is The General Purpose Register In 8085 Microprocessor?
- What Is Microprocessor Instruction?
- I Really Need To Get My All In 1 Printer Worker, But I Am Not Wanting To Download A Bunch Of Things On My Computer, It Don't Need It , I Just Had It Rebuilt Which Is The Reason Why My All In 1 Software Is No Longer On Here. Please Help?
- How Can I Just Connect My All In 1 Printer To My Computer Without The Disk, Although Using A Online Source To Help Get It Working Properly, Without Having To Download Any Said Software The Sites Claim Are Required For It To Work Properly?
- How Do I Connect To The Internet Overseas On A Laptop?
- What Materials Are Used To Make Dark Ink?
- Computer Viruses Are Unwanted Viruses On The Computer. Explain Thier Life Cycle & How It Can Be Eliminated?
- Computer Viruses Are Unwanted Viruses On The Computer. Explain The Life Cycle & How It Can Be Prevented?
- Where To Buy A XCM 360 SATA 2 USB Cable At Stores?
- What To Do When My Babbage Netbook Is Unlocked?
- Can You Explain The Statement That Language Is Symbolic And Person Centered?
- Which Output Statement Is Used In C++ Language?
- Which Statement Is Used For Input In C++ Language?
- How To Call A Function Again In Case Statement In C Language?
- Can You Explain The Statement?
- Can You Explain Statement In Lieu Of Prospectus?
- Can You Explain The Company Mission Statement?
- How Do Explain Bank Reconciliation Statement ?

New Comment - Comments are editable for 5 min.