Simple if statement in C++
Simple if Syntax
The form of an if statement is as follows:



Practice Programs
(i)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5;
if(x)
cout<<"EngineersTutor.com";
return 0;
}
(ii)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5;
if(x>10)
cout<<"EngineersTutor.com";
return 0;
}
(iii)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5;
if(x == 10)
cout<<"EngineersTutor.com";
return 0;
}
(iv)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5, y = 10;
if(x+y)
cout<<"EngineersTutor.com";";
return 0;
}
(v)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5, y = 10;
if( (x+y)>30 )
cout<<"EngineersTutor.com";
return 0;
}
(vi)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5, y = 10;
if( (x+y)>30 )
{
cout<<"EngineersTutor.com";
cout<<"Teach Easy";
}
return 0;
}
(vii)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5, y = 10;
if( (x+y)<30 )
cout<<"EngineersTutor.com"<<endl;
cout<<"Teach Easy"<<endl;
cout<<"Albert"<<endl;
cout<<"Stephen";
return 0;
}
(vii)
#include<iostream>
using namespace std;
int main()
{
system("color ec");
// e = = light yellow = Output window background color
//c = = Light red = Output window text color
int x = 5, y = 10;
if( (x+y)<30 )
cout<<"EngineersTutor.com"<<endl;
cout<<"Teach Easy"<<endl;
cout<<"Albert"<<endl;
cout<<"Stephen";
return 0;
}







