1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
PIT_PIT [208]
2 years ago
5

2. Write a simple program in C++ to investigate the safety of its enumeration types. Include at least 10 different operations on

enumeration types to determine what incorrect or just silly things are legal. Now, write a C program that does the same things and run it to determine how many of the incorrect or silly things are legal. Compare your results.

Computers and Technology
1 answer:
erastovalidia [21]2 years ago
6 0

Answer:

Check the explanation

Explanation:

To solve the question above, we will be doing some arithmetic and bit wise operations on enum values. in addition to that, we are asserting the array with INTCOUNT  and also printing the size of array i.e 12 and we are adding BIG_COUNT enum value to 5 and the result is 25.

#include<stdio.h>

enum EnumBits

{

ONE = 1,

TWO = 2,

FOUR = 4,

EIGHT = 8

};

enum Randoms

{

BIG_COUNT = 20,

INTCOUNT = 3

};

int main()

{

// Basic Mathimatical operations

printf("%d\n",(ONE + TWO)); //addition

printf("%d\n",(FOUR - TWO)); //subtraction

printf("%d\n",(TWO * EIGHT)); //multiplication

printf("%d\n",(EIGHT / TWO)); //division

// Some bitwise operations

printf("%d\n",(ONE | TWO)); //bitwise OR

printf("%d\n",(TWO & FOUR)); //bitwise AND

printf("%d\n",(TWO ^ EIGHT)); //bitwise XOR

printf("%d\n",(EIGHT << 1)); //left shift operator

printf("%d\n",(EIGHT >> 1)); //right shift operator

// Initialize an array based upon an enum value

int intArray[INTCOUNT]; // declaring array

// Have a value initialized be initialized to a static value plus

int someVal = 5 + BIG_COUNT; //adding constant and BIG_COUNT variable

printf("%d\n",someVal); //value will be 25

printf("%d",sizeof(intArray)); //value will be 12

return 0;

}

Kindly check the attached image below for the Code and Output Screenshots:

You might be interested in
What is the difference between a switch's physical interface and the vlan interface?
Andreyy89
<span>Switch's physical interface is something as the name itself suggests itself that it is a physical port to which you can plug in a cable or a wire based on its function and usage where as VLAN interface is no physical port but are created virtually when needed.</span>
4 0
3 years ago
Read 2 more answers
Which of the following is the best description of the [Drive for] block?
Ede4ka [16]
The answer is C to this question
6 0
2 years ago
What are some other ways to program a robot to navigate a complicated environment other than straight paths and right angle (90
In-s [12.5K]

Answer:

The most popular method of robot programming is probably the teach pendant. ... To program the robot, the operator moves it from point-to-point, using the buttons on the pendant to move it around and save each position individually. When the whole program has been learned, the robot can play back the points at full speed.

8 0
3 years ago
Read 2 more answers
RSA encryption relies on
oee [108]

Answer:

the difficulty in factoring large numbers

 a public key that the server and the user’s computer know

 

the use of prime numbers

a private key that only the server knows

Explanation:

ege 2021

5 0
2 years ago
The themes gallery is located on the _____ ribbon tab
Mrac [35]
The themes gallery is located on the "design" ribbon tab
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which is NOT a type of SD card?
    8·2 answers
  • What does SIP stand for?
    5·2 answers
  • Test Average and Grade
    12·1 answer
  • Data as a service began with the notion that data quality could happen in a centralized place, cleansing and enriching data and
    15·1 answer
  • In which step of writing a program does a programmer first use a<br> compiler?<br> documentin
    6·1 answer
  • What behaviors are most common in a successful entrepreneurship
    9·1 answer
  • A student registers for a course in a university. Courses may have limited enrollment i.e a student must
    5·1 answer
  • Kristi, an event planner, wants to store caterers’ names and contact information in an organized manner. Kristi will MOST LIKELY
    13·1 answer
  • What is the next line?
    7·1 answer
  • Can a dod activity enter into a service contract for a military flight simulator without getting a waiver from the secretary of
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!