Advertisement



< Prev
Next >


C++ If Statement





In C++ language, the If statement is used when we want to test a condition, which is evaluated for a boolean value - true or false.




Note:





Advertisement




C - if statement example


// C++ - if statement program 

#include<iostream>

using namespace std;
int main()
{
if(5>5)
	cout<<"5 is greater than 5"<<"\n";

	
if(5<100)
{
	cout<<"5 is less than 100"<<"\n";
	cout<<"Second statement to execute"<<"\n";
}


if(10>4)
{
	cout<<"10 is greater than 4"<<"\n";
}


cout<<"Statement outside If Statement"<<"\n"; //not associated with any if block

return 0;
}


Output is -


5 is less than 100
Second statement to execute
2 is greater than 4
Statement outside If Statement



Program Analysis


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

C#, PYTHON and DJANGO


Advertisement