C++ Program with Enumeration - enum
Code:
Sample Output:
Comment bellow for your Query and Feedback
Code:
/*C++ Program with Enumeration - enum*/
#include<iostream.h>
#include<conio.h>
enum shape
{
circle,
rectangle,
triangle,
};
int main()
{
clrscr();
cout<<"\n Enter Shape Code:\n ";
int code;
cin>>code;
while(code>=circle && code<=triangle)
{
switch (code)
{
case circle:
cout<<" Its a circle";
break;
case rectangle:
cout<<" Its a rectangle";
break;
case triangle:
cout<<" its a triangle";
break;
}
cout<<"\n Enter Shape Code:\n ";
cin>>code;
}
return 0;
}
#include<iostream.h>
#include<conio.h>
enum shape
{
circle,
rectangle,
triangle,
};
int main()
{
clrscr();
cout<<"\n Enter Shape Code:\n ";
int code;
cin>>code;
while(code>=circle && code<=triangle)
{
switch (code)
{
case circle:
cout<<" Its a circle";
break;
case rectangle:
cout<<" Its a rectangle";
break;
case triangle:
cout<<" its a triangle";
break;
}
cout<<"\n Enter Shape Code:\n ";
cin>>code;
}
return 0;
}
Sample Output:
Comment bellow for your Query and Feedback
Y its taking 0,1,2 as input
ReplyDelete