Write C++ statements that do the following:
Define an enum type, birdType, with the values PEACOCK, SPARROW, CANARY, PARROT, PENGUIN, OSTRICH, EAGLE, CARDINAL, and HUMMINGBIRD.
Declare a variable bird of the type birdType.
Assign CANARY to the variable bird.
Advance bird to the next value in the list.
Decrement bird to the previous value in the list.
Output the value of the variable bird.
Input value in the variable bird.
Write C++ statements that do the following:
Define an enum type, birdType, with the values PEACOCK, SPARROW, CANARY, PARROT, PENGUIN, OSTRICH, EAGLE, CARDINAL, and HUMMINGBIRD.
Declare a variable bird of the type birdType.
Assign CANARY to the variable bird.
Advance bird to the next value in the list.
Decrement bird to the previous value in the list.
Output the value of the variable bird.
Input value in the variable bird.
Answer:
a) An enum is defined named birdType, some values are also
defined as asked by the user
Solution:
enum birdType{ PEACOCK, SPARROW, CANARY, PARROT, PENGUIN, OSTRICH,
EAGLE, CARDINAL,
HUMMINGBIRD };
b) Declare a variable bird of the type birdType.
Solution:
birdType bird;
c) Assign CANARY to the variable bird.
Solution:
bird = CANARY;
d) Advance bird to the next value in the list.
Solution:
bird = static_cast<birdType>(int(bird)+1);
e) Output the value of the variable bird.
Solution: Use switch case to output the value of the variable
bird.
switch(bird)
{
case PEACOCK : std::cout << "PEACOCK\n"; break;
case SPARROW: std::cout << "SPARROW\n"; break;
case CANARY : std::cout << "CANARY\n"; break;
case PARROT : std::cout << "PARROT\n"; break;
case PENGUIN: std::cout << "PENGUIN\n"; break;
case OSTRICH : std::cout << "OSTRICH\n"; break;
case EAGLE : std::cout << "EAGLE\n"; break;
case CARDINAL: std::cout << "CARDINAL\n"; break;
case HUMMINGBIRD : std::cout << "HUMMINGBIRD\n"; break;
}
f) Input a value (from the user) in the variable bird.
solution: int input; cin>>input; bird =
static_cast<birdType>(input);
g.Input value in the variable bird
Answer: string
bird1;Cin>>bird1;
If(bird1==”Peacock”)
code :
#include <iostream>
using namespace std;
//(a)enum birdType defined with some values
enum birdType{ PEACOCK, SPARROW, CANARY, PARROT, PENGUIN, OSTRICH,
EAGLE, CARDINAL,
HUMMINGBIRD };
//start the main() function
int main()
{
//(b) Declare a variable bird of the type birdType
birdType bird;
//(c) Assign CANARY to the variable bird.
bird = CANARY;
//(d) Advance bird to the next value in the list.
bird = static_cast<birdType>(int(bird)+1);
//(e) Use switch statement to Output the value of the variable
bird
switch(bird)
{
case PEACOCK : std::cout << "PEACOCK\n"; break;
case SPARROW: std::cout << "SPARROW\n"; break;
case CANARY : std::cout << "CANARY\n"; break;
case PARROT : std::cout << "PARROT\n"; break;
case PENGUIN: std::cout << "PENGUIN\n"; break;
case OSTRICH : std::cout << "OSTRICH\n"; break;
case EAGLE : std::cout << "EAGLE\n"; break;
case CARDINAL: std::cout << "CARDINAL\n"; break;
case HUMMINGBIRD : std::cout << "HUMMINGBIRD\n"; break;
}
int input;
cout<<"Enter new value for bird: ";
//(f) Input a value (from the user)
cin>>input;
//(f) Store the inputted value by the user to the variable
bird.
bird = static_cast<birdType>(input);
//Display the result of the new inputted variable.
switch(bird)
{
case PEACOCK : std::cout << "PEACOCK\n"; break;
case SPARROW: std::cout << "SPARROW\n"; break;
case CANARY : std::cout << "CANARY\n"; break;
case PARROT : std::cout << "PARROT\n"; break;
case PENGUIN: std::cout << "PENGUIN\n"; break;
case OSTRICH : std::cout << "OSTRICH\n"; break;
case EAGLE : std::cout << "EAGLE\n"; break;
case CARDINAL: std::cout << "CARDINAL\n"; break;
case HUMMINGBIRD : std::cout << "HUMMINGBIRD\n"; break;
}
return 0;
}
simple output:

Thankyou i hope it helps you please like it.
Write C++ statements that do the following: Define an enum type, birdType, with the values PEACOCK,...
C language not C++
1. Write the statements to do the following: (2 pts) a. Define a struct with member variables width, height, topleft x, topleft y all floats). Use a tag to call it Rectangle. b. Declare a variable struct type Rectangle 2. Consider the following variables: struct int x; float y; char zi var1; union nt x; float y; char[20] z;) var2 f float and int are stored using 4 bytes each, what is the size (in bytes)...
You are creating a new data type for tracking student’s grades. Create a C++ project in your development tool. Add the header comment and the header files from your C++template.cpp file. Your program should do the following: • Declare an Enum named Grade. The Enum should have the grades A-F and have each grade correspond with A = 90, B = 80, C = 70, D = 60, F = 50. • Declare a variable of Grade type in your...
Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...
Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered. To get proper credit, name the variables as listed below and follow the directions carefully. Do not use any break or similar type of statements. To implement the above code, you will need to count the entries - name the counter variable num_count. You will also need to use a variable,...
using visual studio
2) For each of the following, write C++ statements that perform the specified task.. (Ref: classwork named pointer2) a) Declare a built-in array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10. b) Declare a pointer vPtr that points to a variable of type unsigned int. c) Write two separate statements that assign the starting address of array values to pointer variable vPtr. d) Use...
Write a single C++ statements to accomplish each of the following tasks: In one statement, assign the sum of the current value of x and y to z and postincrement the value of x. Determine whether the value of the variable count is greater than 10. If it is, print “Count is greater than 10.”. Pre-decrement the variable of x by 1, then subtract it from the variable total. Multiply variable power by x and assign the result to power. ...
Write a C program that will do the following: 1.Declare four integers variables. intVar1, intVar2, intVar3,and intVar4. 2. Initialize intVar1 to the value 4; initialize intVar2to the value 5. 3. Declare four more integer variables. exp1, exp2,exp3, and exp4. 4. Declare a character variable charVar. 5. Assign the value of each expression below to variables exp1and exp2 respectively: exp1= intVar1 + ((5 * intVar2) / (3 * intVar1)); exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1; 6....
a) Declare and instantiate an array named scores of twenty-five elements of type int. (b)Write a statement that declares an array namedstreetAddress that contains exactly eighty elements of typechar. 2. In a single statement: declare, create and initialize an arraynamed a of ten elements of type int with the values of the elements (starting with the first) set to 10, 20,..., 100 respectively. 3. Declare an array reference variable, week, and initialize it to an array containing the strings "mon",...
Assignment #1: Write a C++ Program. Consider the following program segment. // Name: Your Name // MU ID: Your ID // include statement (s) l using namespace statement int main() //variable declaration //executable statements // return statement a. Include the header files isotream. b. Include cin, cout, and endl. c. Declare two variables: numi, num2, num3, and average of type int. d. Assign 125 into numi, 28 into num2, and -25 into num3 e. Store the average of numi, num2,...
Using C++
1) Write a function that receives the numerator and denominator of a fraction and returns its corresponding value as a double precision real number. The function also receives the number of digits that the value must be rounded to before returned. To test it, you must implement the algorithm provided below. Note: You must define the most appropriate type of function, the parameter list (using the most appropriate parameters), and the body of the function to be implemented....