// for else statement like pythonfor(int i =0; i < foo; i++){if(breakCondition(i))goto breakLabel;// use goto instead of break;}baz();// only activate baz if for was not "broken"
breakLabel://...//
// Program to check whether an integer is positive, negative or zero#include<iostream>usingnamespace std;intmain(){int number;
cout <<"Enter an integer: ";
cin >> number;if(number >0){
cout <<"You entered a positive integer: "<< number << endl;}elseif(number <0){
cout <<"You entered a negative integer: "<< number << endl;}else{
cout <<"You entered 0."<< endl;}
cout <<"This line is always printed.";return0;}
// C++ program to illustrate if-else statement#include<iostream>usingnamespace std;intmain(){int i =20;if(i <15)
cout<<"i is smaller than 15";else
cout<<"i is greater than 15";return0;}
// C program to illustrate If statement#include<stdio.h>intmain(){int i =20;if(i <15){printf("i is smaller than 15");}else{printf("i is greater than 15");}return0;}
// Program to check whether an integer is positive or negative// This program considers 0 as a positive number#include<iostream>usingnamespace std;intmain(){int number;
cout <<"Enter an integer: ";
cin >> number;if(number >=0){
cout <<"You entered a positive integer: "<< number << endl;}else{
cout <<"You entered a negative integer: "<< number << endl;}
cout <<"This line is always printed.";return0;}
// Program to check whether an integer is positive, negative or zero#include<iostream>usingnamespace std;intmain(){int number;
cout <<"Enter an integer: ";
cin >> number;if(number >0){
cout <<"You entered a positive integer: "<< number << endl;}elseif(number <0){
cout <<"You entered a negative integer: "<< number << endl;}else{
cout <<"You entered 0."<< endl;}
cout <<"This line is always printed.";return0;}
if(boolean_expression 1){// Executes when the boolean expression 1 is true}elseif( boolean_expression 2){// Executes when the boolean expression 2 is true}elseif( boolean_expression 3){// Executes when the boolean expression 3 is true}else{// executes when the none of the above condition is true.}