nuriddin152

Nuriddin152

Posted on March 23, 2023

C++ if

Hello everyone
today we will talk about if in C++

You can use these conditions to perform different actions for different decisions

The C++ programming language has the following selection statements:

  1. Use if to specify a block of code to execute if a specified condition is true.

  2. Use else to define a block of code that executes if the first condition is false.

  3. If the first condition is false, use else if to specify a new condition to test.

  4. Use a switch to specify multiple alternative blocks of code to be executed.

The if statement.

if - Use the if statement to specify a block of C++ code to execute if a condition is true.

if (condition) 
{
  // block of code to be executed if the condition is true
}
Enter fullscreen mode Exit fullscreen mode

Note that if written in lowercase letters. Converting to uppercase (IF or IF) will cause an error.

In the following example, we test two values ​​to determine whether 20 is greater than 18. If the condition is true, print the text:

#include <iostream>
using namespace std;

int main()
{

int num 80;
int num1 = 70;

if(num > num1)
{
cout << "80 is greater than 70";
}

return 0;
}
Enter fullscreen mode Exit fullscreen mode
πŸ’– πŸ’ͺ πŸ™… 🚩
nuriddin152
Nuriddin152

Posted on March 23, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

C++ da birinchi dars
cpp C++ da birinchi dars

September 20, 2023

C++ else
cpp C++ else

March 23, 2023

C++ if
cpp C++ if

March 23, 2023