Saturday, December 2, 2017

Conditional Statements in C++ and Python (part 1)

if conditional statement

A condition is checked and execute statement/block of statements if the condition is true.


C++ Python
Syntax

if (condition)
{
        statement1;
        statement2;
                ...
}
Syntax

if condition:
        statement1;
        statement2;
                ...



Example

int a = 10;
int b = 15;

if (a<b)
{
      cout<<"a < b.";
}
Example

a,b = 10, 15;

if a<b:
     print("a < b")




No comments:

Post a Comment

Iterative statements in C++ and Python (Part 2)

for loop iterative statements Executing set of statements using for iterative statement in C++ and Python is quite different. First, l...