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
You are finally at the stage of the software life cycle where you begin programming. What is this stage called?
nataly862011 [7]
You are finally at the stage of the software life cycle where you begin programming. What is this stage called?

development

5 0
2 years ago
What is the best definition for a relationship?
velikii [3]

Answer:

special instance of a dataset

7 0
3 years ago
1. Target area range is a survey of what lies about __________ seconds ahead of the vehicle. A. 5-10 B. 10-20 C. 20-30 D. 40-50
pshichka [43]

Answer:

Target area range is a survey of what lies about 12-20 seconds ahead of the vehicle. Correct Answer is B. (10-20 second)

Explanation:

Target area range is the space between your vehicle and the target area. A target area is an area on the roadway where the target is located. A target can be anything such as a car, a traffic signal, a blackhead, etc.

Target area range is also a section of roadway where the target is located and the area to the left and right of the target area

4 0
3 years ago
Read 2 more answers
23+ Composition refers to
Law Incorporation [45]

Answer:

c. The placement and relationship of  elements within a picture

Explanation:

Required

What composition means?

Literally, composition means the way the elements of a picture are presented. The elements in this case constitute all lines, shapes, dots, pattern and many more.

You will notice that some of these elements will be placed over one another, some side by side, some far from one another.

So, composition means the way these elements are displayed.

<em>Hence, option (c) is correct.</em>

3 0
2 years ago
41. Which is NOT a valid statement to initialize a variable?
ollegr [7]

I think its c I hope I'm not wrong about this If I am I'm sorry

5 0
3 years ago
Other questions:
  • A type TW cable containing two No. 12 copper conductors has a maximum overcurrent protection of
    7·2 answers
  • Missy creates a personal budget. She enters her current savings account balance in cell D3. In cell A3, she calculates her incom
    13·2 answers
  • Read the following scenario: A project will require more people than originally estimated. Identify the possible risks to the pr
    8·2 answers
  • Which sentence(s) below are true?a. IP stands for Internet Protocol.b. In most home networks IP addresses are assigned by the In
    6·1 answer
  • host b is sending an email intented for the user on host a to the mail server what protocol is being used to send the message
    10·1 answer
  • question i need a real answer cuase i have a virus cuase off my borther and these are the notifacations i get and now these site
    11·1 answer
  • Rate my dog out of ten give explanation why
    12·1 answer
  • How do you use switch board in the office​
    6·1 answer
  • Olivia wants to change some settings in Outlook. What are the steps she will use to get to that function? open Outlook → File →
    7·2 answers
  • Immigrants are allowed to enter the country to work when they have a(n)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!