1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <conio.h> // For function getch()
#include <cstdlib> // For several general-purpose functions
#include <fstream> // For file handling
#include <iomanip> // For formatted output
#include <iostream> // For cin, cout, and system
#include <string> // For string data type
using namespace std; // So "std::cout" may be abbreviated to "cout"
int main()
{
char sym;
char B, C, F, H, N, O;
cout << "Please Enter a single upper-case element symbol: ";
cin >> sym;
if (sym = B)
{
cout << "Element: Boron, Atomic Number: 5";
}
if (sym = C)
{
cout << "Element: Carbon, Atomic Number: 6";
}
if (sym = F)
{
cout << "Element: Fluorine, Atomic Number: 9";
}
if (sym = H)
{
cout << "Element: Hydrogen, Atomic Number: 1";
}
if (sym = N)
{
cout << "Element: Nitrogen, Atomic Number: 7";
}
if (sym = O)
{
cout << "Element: Oxygen, Atomic Number: 8";
}
else (sym != B, C, F, H, N, O);
{
cout << "Error, the symbol entered is invalid.";
}
}
|