MyLab Programming with Pearson eText -- Access Card -- for Starting Out with C++ from Control Structures to Objects (My Programming Lab)
9th Edition
ISBN: 9780134484198
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 11.11, Problem 11.21CP
Program Plan Intro
Enumeration:
Enumeration is a user-defined data type which consists of enumerators; the enumerators are used to represent integer constants.
- An enumeration can be defined by using the keyword “enum”.
- By default, the values of enumeration type are filled with “0” to “n” sequentially and those default values can be changed when declaring the enumeration.
- In a sequence of enumerators, if the first enumerator is assigned with a “user-defined value” and the next enumerator is not assigned with any value, then by default the next enumerator will be filled by the value “user-defined value of previous enumerator plus 1”.
- The type name of an enumeration is optional; if name of the enumeration type is not given then it is referred as “anonymous”.
Syntax:
Syntax to declare an enumerated data type is as follows,
enum type_name {identifier_1, identifier_2, identifier_3, … identifier_n};
In the above syntax,
- “enum” is the keyword used to declare an enumerator.
- “type_name” refers the name of the type of the enumerator.
- “identier_1” to “identifier_n” are refers the list of the identifiers declared in the enumerator.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is pass-by-value? What is pass-by-reference? Show the result of the following programs:
please code this for me in c++ using void, functions, loops, (basic c++ not complicated or highlevel please). I tried to code it myself but there are many mistakes I dont know how to fix so please write a similar one for me but it works.
The question is only 1 but it has 2 parts (2 different functions that should be in one code)
MY CODE:
#include <iostream>using namespace std;
int IsPalindrome(int p);void GCD();
int main (){ int choice; cout << "Please enter a choice: "<<endl; cout << "Enter one for IsPalindrome "<<endl; cout << "Enter 2 for GCD "<<endl; cout << "Enter 3 to exit the program "<<endl; cout << "Choice: "<<endl; cin >> choice; if (choice == 1) { int p; cout << "Please enter a 3 digit number: "<<endl; cin >> p;
if(p%10==p/100) { cout<<p<<" is a palindrome " <<endl; }
else {…
I need help understanding each line of code. Can you please explain each line of code so I can fully understand what is going on step by step? I have experience in c++ so maybe you can also point out some differences between this code and c++ code. Thank you!
#include <stdio.h>
int main(void)
{
char *stringPtr = "Hello world.\n";
while (*stringPtr != '\0')
{
printf("%p: ", stringPtr);
printf("0x%02x\n", *stringPtr);
stringPtr++;
}
printf("%p: ", stringPtr);
printf("0x%02x\n", *stringPtr);
return 0; }
Chapter 11 Solutions
MyLab Programming with Pearson eText -- Access Card -- for Starting Out with C++ from Control Structures to Objects (My Programming Lab)
Ch. 11.4 - Prob. 11.1CPCh. 11.4 - Write a definition statement for a variable of the...Ch. 11.4 - Prob. 11.3CPCh. 11.6 - For Questions 11.4-11.7 below, assume the Product...Ch. 11.6 - Write a loop that will step through the entire...Ch. 11.6 - Prob. 11.6CPCh. 11.6 - Prob. 11.7CPCh. 11.6 - Write a structure declaration named Measurement,...Ch. 11.6 - Write a structure declaration named Destination,...Ch. 11.6 - Write statements that store the following data in...
Ch. 11.10 - Prob. 11.11CPCh. 11.10 - Write a function that uses a Rectangle structure...Ch. 11.10 - Prob. 11.13CPCh. 11.10 - Prob. 11.14CPCh. 11.10 - Prob. 11.15CPCh. 11.11 - Look at the following declaration: enum Flower {...Ch. 11.11 - What will the following code display? enum {...Ch. 11.11 - Prob. 11.18CPCh. 11.11 - What will the following code display? enum Letters...Ch. 11.11 - Prob. 11.20CPCh. 11.11 - Prob. 11.21CPCh. 11 - Prob. 1RQECh. 11 - Prob. 2RQECh. 11 - Prob. 3RQECh. 11 - Look at the following structure declaration:...Ch. 11 - Look at the following structure declaration:...Ch. 11 - Look at the following code: struct PartData {...Ch. 11 - Look at the following code: struct Town { string...Ch. 11 - Look at the following code: structure Rectangle {...Ch. 11 - Prob. 9RQECh. 11 - Look at the following declaration: enum Person {...Ch. 11 - Prob. 11RQECh. 11 - The ______ is the name of the structure type.Ch. 11 - The variables declared inside a structure...Ch. 11 - A(n) ________ is required after the closing brace...Ch. 11 - In the definition of a structure variable, the...Ch. 11 - Prob. 16RQECh. 11 - Prob. 17RQECh. 11 - Prob. 18RQECh. 11 - Prob. 19RQECh. 11 - Prob. 20RQECh. 11 - Declare a structure named TempScale, with the...Ch. 11 - Write statements that will store the following...Ch. 11 - Write a function called showReading. It should...Ch. 11 - Write a function called findReading. It should use...Ch. 11 - Write a function called getReading, which returns...Ch. 11 - Prob. 26RQECh. 11 - Prob. 27RQECh. 11 - Look at the following statement: enum Color { RED,...Ch. 11 - A per store sells dogs, cats, birds, and hamsters....Ch. 11 - T F A semicolon is required after the closing...Ch. 11 - T F A structure declaration does not define a...Ch. 11 - T F The contents of a structure variable can be...Ch. 11 - T F Structure variables may not be initialized.Ch. 11 - Prob. 34RQECh. 11 - Prob. 35RQECh. 11 - T F The following expression refers to element 5...Ch. 11 - T F An array of structures may be initialized.Ch. 11 - Prob. 38RQECh. 11 - T F A structure member variable may be passed to a...Ch. 11 - T F An entire structure may not be passed to a...Ch. 11 - T F A function may return a structure.Ch. 11 - T F when a function returns a structure, it is...Ch. 11 - T F The indirection operator has higher precedence...Ch. 11 - Prob. 44RQECh. 11 - Find the Errors Each of the following...Ch. 11 - Prob. 46RQECh. 11 - struct TwoVals { int a, b; }; int main () {...Ch. 11 - #include iostream using namespace std; struct...Ch. 11 - #include iostream #include string using namespace...Ch. 11 - struct FourVals { int a, b, c, d; }; int main () {...Ch. 11 - Prob. 51RQECh. 11 - struct ThreeVals { int a, b, c; }; int main () {...Ch. 11 - Prob. 1PCCh. 11 - Movie Profit Modify the program written for...Ch. 11 - Prob. 3PCCh. 11 - Weather Statistics Write a program that uses a...Ch. 11 - Weather Statistics Modification Modify the program...Ch. 11 - Soccer Scores Write a program that stores the...Ch. 11 - Customer Accounts Write a program that uses a...Ch. 11 - Search Function for Customer Accounts Program Add...Ch. 11 - Speakers Bureau Write a program that keeps track...Ch. 11 - Prob. 10PCCh. 11 - Prob. 11PCCh. 11 - Course Grade Write a program that uses a structure...Ch. 11 - Drink Machine Simulator Write a program that...Ch. 11 - Inventory Bins Write a program that simulates...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Hello, This is part of my hangman simulation in C++. If you compile and run it and type "Easy," the code should run. If you run it though, the body of the hangman doesn't align when you guess wrong. Could you help me with that and implement an if statement to repeat the program if user wants to play again? #include <iostream> #include <cstdlib> #include <ctime> #include <string> #include <iomanip>using namespace std; const int MAX_TRIES = 5;char answer; int letterFill(char, string, string&); int main() { string name; char letter; int num_of_wrong_guesses = 0; string word; srand(time(NULL)); // ONLY NEED THIS ONCE! // welcome the user cout << "\n\nWelcome to hangman!! Guess a fruit that comes into your mind."; // Ask user for for Easy, Average, Hard string level; cout << "\nChoose a LEVEL(E - Easy, A - Average, H - Hard):" << endl; cin >> level; // compare level if (level == "Easy") {//put all the string inside…arrow_forwardI need your help with the question attached, Your writing your program in C# . When writing or printing out the output of your code please use the format when writing your code and when you want to print out the data too static void Main(string[] args) { int student_id; int student_pass, highest_avgerage_id, student_fail; student_pass = 0; student_fail = 0; highest_avgerage_id = 0; Console.Write("Enter a student id (0 to quit): "); student_id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Number of student who are moving on: " + student_pass); Console.WriteLine("Number of student who are not moving on: " + student_fail); if (student_id == 0) { is_continue = false; break; } This is the format I need any tutor working on this to use when they are solving the problem and writing the code in C# please. Please let me know if…arrow_forwardCan you please answer the question in short according to the code it. It has been done in C++ #include "StudentInfo.h" #include //InitializeInfo - returns void, accepts the address of struct StudentInfo void InitializeInfo(StudentInfo *s) { int i; strcpy(s->lastname,"\0"); s->studentID=0; for(i=0;i { strcpy(s->subject[i].name,"\0"); s->subject[i].marks=0; } } //AverageMark - returns float, accepts the address of struct Subject float AverageMark (Subject s[]) { float sum=0,avg; int i; for(i=0;i { if(s[i].marks==0) break; sum=sum+s[i].marks; } avg=sum/NUM_SUBJRCTS; return avg; } //MaximumMark - returns integer, accepts the address of struct Subject int MaximumMark(Subject s[]) { int i,max; max=s[0].marks;//let first is maximum for(i=0;i { if(s[i].marks max=s[i].marks; if(s[i].marks==0) break; } return max; } //MinimumMark - returns integer, accepts the address struct Subject int MinimumMark (Subject s[]) { int i,min; min=s[0].marks;//let first is minimum for(i=0;i {…arrow_forward
- I am having issues with C++ because this code does not work: int main() {int userNum; userNum = 5;cout << "Foretelling is hard." << endl;cout << "Particularly of the future." << endl;cout << "User num is:" << userNum << endl;/* Your solution goes here */ return 0; Please tell me what to do with this line of code.arrow_forwardThe below code is the code that it’s mentioned in the question! Please write your in C language, and put it in text so i can copy it! Thanksarrow_forwardCan you write code according to the desired conditions ?arrow_forward
- What is the problem in this code?arrow_forwardI used to do programming in C++ but in my current project I am using Python3 and since we don't use keywords that define the datatype of any variable so I am having trouble in typecasting an integer value to a char value. So, please show how to typecast an integer value to char value in Python3.arrow_forwardPlease change the code so it will work with C PROGRAMING NOT C#. Thank you. using System;class Program{ static void Main(string[] args) { Console.WriteLine("Please enter the number above 0:"); int userNumber=Convert.ToInt32(Console.ReadLine()); if(userNumber<0) { Console.WriteLine("Number must be above 0:"); } Console.WriteLine("Assending:"); for(int i=0;i<=userNumber;i++) { Console.Write(i+" "); } Console.WriteLine(); Console.WriteLine("Desending:"); for(int i=userNumber;i>=0;i--) { Console.Write(i+" "); } Console.WriteLine(); }}arrow_forward
- a) What is the risk of using strcpy() in C given the code below? void f1(char *str2) { int y; char str1[10]; strcpy(str1, str2);arrow_forwardI am needing assistance with the following program build in C++. To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters. Also output the – (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.arrow_forwardQuestion 10 Write a program in Java that finds the Least common multiple of 2 numbers,please include comments and fully explain what the code does because I am not really understanding what loops are doing ! (I need a manual way to calculate the lcm and not use a function(method) or "findlcm"..!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education