Friday 9 November 2012

C Program to Print Enumerated Variables

#include<stdio.h>
#include<io.h>
void main()
{
 enum a{x=111,y=222,z=333};
 enum a b;
 b=z;
 printf("\nThe enum x is %d",x);
 printf("\nThe enum y is %d",y);
 printf("\nThe enumeration variable b is %d",b);
}

Click here to download the C Program.


/* You don't need typecasting to print enumerated variables. But the following Program will also work. */


#include<stdio.h>
#include<io.h>
void main()
{
 enum a{x=111,y=222,z=333};
 enum a b;
 b=z;
 printf("\nThe enum x is %d",(int)x);
 printf("\nThe enum y is %d",(int)y);
 printf("\nThe enumeration variable b is %d",(int)b);
}


Click here to download the C Program.
 

No comments:

Post a Comment