-->

program to understand enum data type

using codeblocks
---------------------------------------------------------------------------------------------------
//enum simple program
#include <stdio.h>
#include <stdlib.h>
enum computer{samsung,LG,apple,hp,acer}; // list of values of enum. value location starts from 0.
enum computer find;                    //variable for computer

int main()
{
    find=acer;                          // assigning position of value acer in set
    printf("location of acer=%d\n",find);// display that
    return 0;
}

//or
/*
//enum simple program
#include <stdio.h>
#include <stdlib.h>

int main()
{
enum computer{samsung,LG,apple,hp,acer}; // list of values of enum
enum computer find;                    //variable for computer

    find=acer;                          // assigning position of value acer in set
    printf("location of acer=%d\n",find);// display that
    return 0;
}
*/
//note:- we can also put set of value outside and enum variable inside.
----------------------------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------------------------------
//enum simple program
#include <stdio.h>
#include <stdlib.h>
enum computer{samsung,LG,apple,hp,acer}; // list of values of enum. value location starts from 0.
enum computer find;                    //variable for computer

int main()
{
    find=acer;                          // assigning position of value acer in set
    printf("location of acer=%d\n",find);// display that
    return 0;
}

//or
/*
//enum simple program
#include <stdio.h>
#include <stdlib.h>

int main()
{
enum computer{samsung,LG,apple,hp,acer}; // list of values of enum
enum computer find;                    //variable for computer

    find=acer;                          // assigning position of value acer in set
    printf("location of acer=%d\n",find);// display that
    return 0;
}
*/
//note:- we can also put set of value outside and enum variable inside.

No comments:

Post a Comment