#include <iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a= 0);
{
cout<<"a = " << a;
}
}
if (5 == 4) {
//code you want to run if the condition is true
} else {
// code you want to run if the condition is false
}
if( a == 10 ) {
cout << "Value of a is 10" << endl;
} else if( a == 20 ) {
// if else if condition is true
cout << "Value of a is 20" << endl;
}
if (condition)
{
// block of code
}
else if (condition)
{
// block of code
}
else {
// block of code
}
if (condition) {
// block of code to be executed if the condition is true
}
//1
if(condition) {
statement(s);
}
else {
statement(s);
}
//2
(condition) ? (true_statement) : (false_statement)
// C++ program to illustrate if-else statement
#include<iostream>
using namespace std;
int main()
{
int i = 20;
if (i < 15)
cout<<"i is smaller than 15";
else
cout<<"i is greater than 15";
return 0;
}
int time = 22;
if (time < 10) {
cout << "Good morning.";
} else if (time < 20) {
cout << "Good day.";
} else {
cout << "Good evening.";
}
// Outputs "Good evening."
// C program to illustrate If statement
#include <stdio.h>
int main() {
int i = 20;
if (i < 15){
printf("i is smaller than 15");
}
else{
printf("i is greater than 15");
}
return 0;
}
if(condizione){
//Istruzione
}
else{
//Istruzione
}
if (condition) {
// block of code if condition is true
}
else {
// block of code if condition is false
}
if (condition)
{
// Executes this block if
// condition is true
}
else
{
// Executes this block if
// condition is false
}
if(condition)
{
// Statements to execute if
// condition is true
}
// Program to check whether an integer is positive or negative
// This program considers 0 as a positive number
#include <iostream>
using namespace std;
int main() {
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.";
return 0;
}
bool state = (value > 0) ? true : false;
if (condition) {
// body of if statement
}
int time = 20;
if (time < 18) {
cout << "Good day.";
} else {
cout << "Good evening.";
}
// Outputs "Good evening."
1 == 2 || 4
#include <iostream>
include namespace std;
int main() {
int flourBagCount = 16;
if (flourBagCount < 15) {
cout << "There are not enough bags of flour in inventory."
} else {
cout << "There are enough bags of flour in inventory."
}
}
int x = 20;
int y = 18;
if (x > y) {
cout << "x is greater than y";
}
if(boolean_expression 1) {
// Executes when the boolean expression 1 is true
} else if( boolean_expression 2) {
// Executes when the boolean expression 2 is true
} else if( boolean_expression 3) {
// Executes when the boolean expression 3 is true
} else {
// executes when the none of the above condition is true.
}
int time = 20;
string result = (time < 18) ? "Good day." : "Good evening.";
cout << result;
if (variable) {
variable is true
}
Code Example |
---|
Cpp :: Casino Number Guessing Game - C++ |
Cpp :: what is c++ function |
Cpp :: operator overload |
Cpp :: is palindrom |
Cpp :: c++ & operator |
Cpp :: main function |
Cpp :: int to string Using to_string method |
Cpp :: deletion in bst |
Cpp :: declare a variable in cpp |
Cpp :: how to change the type of something in c++ |
Cpp :: trig in c++ |
Cpp :: pre increment vs post increment c++ |
Cpp :: set elements to 42 back |
Cpp :: create a bitset of 1024 bits, |
C :: csrf_exempt |
C :: calculate distance between 2 points X Y axis |
C :: convert from integer to string vb |
C :: div en langage c |
C :: c code to python code converter online |
C :: Creating a process in C |
C :: how to shutdown system c++ |
C :: c 2d array dimensions |
C :: count number of vowels in a string in c |
C :: read from a file c |
C :: connect servo to arduino |
C :: c program to find the factorial of a number |
C :: read a document in c getting name from console |
C :: c fopen |
C :: ** in c |
C :: c pointers |