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;
}

Gopal Krishna

Hey Engineers, welcome to the award-winning blog,Engineers Tutor. I'm Gopal Krishna. a professional engineer & blogger from Andhra Pradesh, India. Notes and Video Materials for Engineering in Electronics, Communications and Computer Science subjects are added. "A blog to support Electronics, Electrical communication and computer students".

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »