-->
Showing posts with label enum data type with value. Show all posts
Showing posts with label enum data type with value. Show all posts

enum data type with value

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

int main()
{

   for(find=samsung;find<=acer;find++)// find variable runs from samsung to acer. The value runs from 1 to 5.

   {
       printf("location of =%d\n",find);// display that. the value increases itself.
   }
    return 0;
}

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

int main()
{
enum computer{samsung=1,LG,apple,hp,acer=5}; // list of values of enum. value location starts from 1.
enum computer find;                         //variable for object "computer"

    for(find=samsung;find<=acer;find++)// find variable runs from samsung to acer. The value runs from 1 to 5.

   {
       printf("location =%d\n",find);// display that. the value increases itself.
   }
    return 0;
}
*/
----------------------------------------------------------------------------------------------------
using turboc++
------------------------------------------------------------------------------------------------------------

//enum simple program
#include <stdio.h>
#include <stdlib.h>
enum computer{samsung=1,LG,apple,hp,acer=5}; // list of values of enum. value location starts from 1.
enum computer find;                         //variable for object "computer"

int main()
{

   for(find=samsung;find<=acer;find++)// find variable runs from samsung to acer. The value runs from 1 to 5.

   {
       printf("location of =%d\n",find);// display that. the value increases itself.
   }
    return 0;
}

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

int main()
{
enum computer{samsung=1,LG,apple,hp,acer=5}; // list of values of enum. value location starts from 1.
enum computer find;                         //variable for object "computer"

    for(find=samsung;find<=acer;find++)// find variable runs from samsung to acer. The value runs from 1 to 5.

   {
       printf("location =%d\n",find);// display that. the value increases itself.
   }
    return 0;
}
*/