Write C statements to do the following a Define an enum type

Write C++ statements to do the following: a. Define an enum type, computerType, with the values DELL, IBM, ACER, SONY, HP b. Declare a variable called myPC of the type computerType c. Assign SONY to the variable myPC. d. Write a C++ statment to display \"My pc is a Dell\" if the value in variable myPC is a DELL and \"My pc is NOT a Dell\" otherwise.

Solution

#include <iostream>

using namespace std;

int main()
{

//define enum type
enum computerType { DELL, IBM, ACER, SONY, HP };

//declare variable myPC
computerType myPC;

//assign sony to myPC
myPC=SONY;

//cpmparing dell with myPC
if(myPC==DELL)

cout << \"My pc is a Dell\" << endl;
else
cout << \"My pc is NOT a Dell\" << endl;
return 0;


}


OUTPUT:
My pc is NOT a Dell

 Write C++ statements to do the following: a. Define an enum type, computerType, with the values DELL, IBM, ACER, SONY, HP b. Declare a variable called myPC of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site