Mario Bradyn
14
Q:

C++ if else

a = 200
b = 33
if b > a:
	print("b is greater than a")

elif a == b:
	print("a and b are equal")

else:
	print("a is greater than b")

 
44
   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;
   } 
5
if bool then
	--code
else
	--code
end
2


  if (condition1) {
  // block of code to be executed if 
  condition1 is true
} else if (condition2) {
  // block of 
  code to be executed if the condition1 is false and condition2 is true

  } else {
  // block of code to be executed if the condition1 is false 
  and condition2 is false
}

  
1
#include<iostream>
using namespace std;

int main()
{
    int grade;

    cin >> grade;

    if( grade >= 60 )
        cout << "You Pass!" << endl;
    else
        cout << "You Fail..." << endl;

    return 0;
}
0


  if (condition) {
  // block of code to be executed if the 
  condition is true
} else { 
  // block of code to be executed 
  if the condition is false
}


  
2
#include<iostream>
using namespace std;

int main()
{
    int grade;

    cin >> grade;

    if( grade >= 60 )
    {
        cout << "You Pass!" << endl;
    }
    else
    {
        cout << "You Fail..." << endl;
    }

    return 0;
}
0

New to Communities?

Join the community