Comparing values of Enum variables






In this we are going to see basic program to compare values of Enum Variables in C++ Programming Language.



The Code given below can be used in TURBO C++ Compilers: -

#include <iostream.h>
#include <conio.h>

void main()
{
    enum flavour
    {
        vanilla = 5,
        chocolate = 7,
        oreo = 8,
        tcoconut = 9,
        blueberry = 6
    };
    flavour f1 = oreo;
    flavour f2 = tcoconut;
    if (f1 > f2)
        cout << "Oreo is the best ice cream flavour with the score of " << f1 << " out of 10";
    else
        cout << "Tender Coconut is the best ice cream flavour with the score of " << f2 << " out of 10";
    getch();
}

//.......Coded by SAHIL SHAIKH


The Code given below can be used in gcc/g++ Compilers: -

#include <iostream>
using namespace std;

int main()
{
    enum flavour
    {
        vanilla = 5,
        chocolate = 7,
        oreo = 8,
        tcoconut = 9,
        blueberry = 6
    };
    flavour f1 = oreo;
    flavour f2 = tcoconut;
    if (f1 > f2)
        cout << "Oreo is the best ice cream flavour with the score of " << f1 << " out of 10";
    else
        cout << "Tender Coconut is the best ice cream flavour with the score of " << f2 << " out of 10";
}

//.......Coded by SAHIL SHAIKH


#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post