Advertisement



< Prev
Next >


C++ If Else Statement





In the if-else statement of C++ language, the condition in the parenthesis of if is evaluated for a boolean value - true or false.







/* C++ if else example */

#include<iostream>

using namespace std;
int main()
{
//Declaring multiple char variables.
char a = 'a', b = 'b';

//An if-else statement comparing values in char variables
if(a<b)
	cout<<"a is less than b";
else
	cout<<"b is greater than a";

return 0;
}


Output -

a is less than b

In the latter program, we have compared values in char variables using an if-else statement, internally their ASCII values have been compared to find out which character has a greater ASCII value.



Please share this article -





< Prev
Next >
< If Statement
Else-If Statement>



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement

Notifications



Please check our latest addition

PYTHON and DJANGO


Advertisement