C++: Using "OR" Boolean Operator [ "||" ]
by matt392 in Circuits > Software
7 Views, 0 Favorites, 0 Comments
C++: Using "OR" Boolean Operator [ "||" ]
C++ Program that uses the "OR" boolean operator. Also uses if-else and else-if statements.
#include <iostream>
#include <string>
using namespace std;
int main()
{ // start main function
string linuxDistribution;
cout << "Enter Linux distribution: ";
cin >> linuxDistribution;
if (linuxDistribution == "Debian" || linuxDistribution == "debian")
{
cout << "Debian uses apt-get.";
} // end if
else if (linuxDistribution == "Fedora" || linuxDistribution == "fedora")
{
cout << "Fedora is part of Red Hat.";
} // end else if
else if (linuxDistribution == "OpenSuse" || linuxDistribution == "opensuse")
{
cout << "OpenSuse uses Yast.";
} // end else if
else if (linuxDistribution == "Kali" || linuxDistribution == "kali")
{
cout << "Kali is a security distribution.";
} // end else if
else if (linuxDistribution == "Slackware" || linuxDistribution == "slackware")
{
cout << "Slackware is an advanced Linux system.";
} // end else if
else if (linuxDistribution == "Arch" || linuxDistribution == "arch")
{
cout << "Arch uses 'pacman'.";
} // end else if
else
{
cout << "There are over 300 Linux distributions!";
} // end else
return 0;
} // end main function
Downloads
Supplies
- Desktop or laptop compuiter
- Code::Blocks IDE for C++
C++ Code Using "OR" Operator " || "
C++ Program that uses the "OR" boolean operator. Also uses if-else and else-if statements.
#include <iostream>
#include <string>
using namespace std;
int main()
{ // start main function
string linuxDistribution;
cout << "Enter Linux distribution: ";
cin >> linuxDistribution;
if (linuxDistribution == "Debian" || linuxDistribution == "debian")
{
cout << "Debian uses apt-get.";
} // end if
else if (linuxDistribution == "Fedora" || linuxDistribution == "fedora")
{
cout << "Fedora is part of Red Hat.";
} // end else if
else if (linuxDistribution == "OpenSuse" || linuxDistribution == "opensuse")
{
cout << "OpenSuse uses Yast.";
} // end else if
else if (linuxDistribution == "Kali" || linuxDistribution == "kali")
{
cout << "Kali is a security distribution.";
} // end else if
else if (linuxDistribution == "Slackware" || linuxDistribution == "slackware")
{
cout << "Slackware is an advanced Linux system.";
} // end else if
else if (linuxDistribution == "Arch" || linuxDistribution == "arch")
{
cout << "Arch uses 'pacman'.";
} // end else if
else
{
cout << "There are over 300 Linux distributions!";
} // end else
return 0;
} // end main function