C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 2, Problem 33SA

Explanation of Solution

The given code snippet is not correctly formatted:

#include <iostream>

#include <string>

using namespace std;                                                                                             (1)

const double X = 13.45;const int Y=18;                                                               (2)(3)

const char STAR= '*';

int main()

{string employeeID;string department; int num;                                               (4)(9)

double salary;                                                                                                         (9)

cout<<"Enter employee ID: "; cin>> employeeID; cout<<endl;                      (5)(6)(9)(10)

cout<<"Enter department: "; cin                                                                        (5)(6)(7)(9)

>>department;                                                                                                       (5)(7)(9)

cout<<endl; cout<<"Enter a positive integer less than 80:";                            (5)(6)(9)(10)

cin>>num;cout<<endl; salary=num*X;                                                              (5)(6)(8)(9)(10)

cout<<"ID: "<< employeeID <<endl;                                                                  (5)(9)(10)

cout<<"Department "<<department<&...

Blurred answer
Students have asked these similar questions
C++ program #include<iostream> #include<fstream> #include<string> using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; struct Customers { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode; char isDeleted; char newLine; }; void add_data(int no_of_records, ofstream& fout) { struct Customers c; cout << "Enter the Customer data:" << endl; cout << "Name:"; cin >> c.name; cout << "Street Address 1:"; cin >> c.streetAddress_1; cout << "Street Address 2:"; cin >> c.streetAddress_2; cout << "City:"; cin >> c.city; cout << "State:"; cin >> c.state; cout << "Zip Code:"; cin >> c.zipCode; cout << endl; c.customerNumber = no_of_records; c.isDeleted = 'N'; c.newLine = '\n'; cout…
#include<iostream>#include<string.h>using namespace std; struct student{    int number;    string name;    int age;    string city;}s[10]; struct module{    int number;    string name;    string code;    int credit;}m[10]; struct assessment{    int number;    int marks1;    int marks2;}a[10]; int index1 =0, index2=0, index3=0; void StudentRegistration(){    if(index1==10)    {        cout<<"No more data can be added"<<endl;        return;    }    string temp;    cout<<"Enter personal data"<<endl;    cout<<"Enter Student Number"<<endl;    cin>>s[index1].number;    cout<<"Enter Student Name"<<endl;    getline(cin, temp);    getline(cin,s[index1].name);    cout<<"Enter Age"<<endl;    cin>>s[index1].age;    cout<<"Enter city"<<endl;    getline(cin,temp);    getline(cin,s[index1].city);    index1++;} void ModuleEnrolment(int id){    if(index2==10)    {        cout<<"No more data can be…
C++ program #include <iostream> #include <string> #include<cstring>   using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; class Customer { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode; public: void setCustomerNumber(long customerNo) { customerNumber = customerNo; } bool setName(char name[]) { if (strlen(name) <= NAME_SIZE) { (this->name, name); returntrue; } returnfalse; } bool setStreetAddress_1(char streetAddress_1[]) { if (strlen(streetAddress_1) <= STREET_SIZE) { (this->streetAddress_1, streetAddress_1); returntrue; } returnfalse; } bool setStreetAddress_2(char streetAddress_2[]) { if (strlen(streetAddress_2) <= STREET_SIZE) { (this->streetAddress_2, streetAddress_2); returntrue; } returnfalse; } bool setCity(char city[]) { if…

Chapter 2 Solutions

C++ Programming: From Problem Analysis to Program Design

Ch. 2 - Which of the following are valid C++ assignment...Ch. 2 - Write C++ statements that accomplish the...Ch. 2 - Write each of the following as a C++ expression....Ch. 2 - Prob. 14SACh. 2 - Suppose x, y, and z are int variables and wandt...Ch. 2 - 16. Suppose x, y, and z are int variables and x =...Ch. 2 - Suppose a and b are int variables, c is a double...Ch. 2 - 18. Write C++ statements that accomplish the...Ch. 2 - Which of the following are correct C++ statements?...Ch. 2 - Give meaningful identifiers for the following...Ch. 2 - 21. Write C++ statements to do the following....Ch. 2 - Prob. 22SACh. 2 - The following program has syntax errors. Correct...Ch. 2 - Prob. 24SACh. 2 - Prob. 25SACh. 2 - Preprocessor directives begin with which of the...Ch. 2 - 27. Write equivalent compound statements if...Ch. 2 - 28. Write the following compound statements as...Ch. 2 - 29. Suppose a, b, and c are int variables and a =...Ch. 2 - Suppose a, b, and sum are int variables and c is a...Ch. 2 - Prob. 31SACh. 2 - Prob. 32SACh. 2 - Prob. 33SACh. 2 - Prob. 34SACh. 2 - 1. Write a program that produces the following...Ch. 2 - Prob. 2PECh. 2 - Prob. 3PECh. 2 - 4. Repeat Programming Exercise 3 by declaring...Ch. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - 7. Write a program that prompts the user to input...Ch. 2 - Prob. 8PECh. 2 - 9. Write a program that prompts the user to enter...Ch. 2 - 10. Write a program that prompts the user to input...Ch. 2 - 11. Write a program that prompts the capacity, in...Ch. 2 - 12. Write a C++ program that prompts the user to...Ch. 2 - 13. To make a profit, a local store marks up the...Ch. 2 - 14. (Hard drive storage capacity) If you buy a 40...Ch. 2 - 15. Write a program to implement and test the...Ch. 2 - 16. A milk carton can hold 3.78 liters of milk....Ch. 2 - 17. Redo Programming Exercise 16 so that the user...Ch. 2 - Prob. 18PECh. 2 - 19. Write a program that prompts the user to input...Ch. 2 - 20. For each used car a salesperson sells, the...Ch. 2 - 21. Newton's law states that the force, , between...Ch. 2 - 22. One metric ton is approximately 2,205 pounds....Ch. 2 - 23. Cindy uses the services of a brokerage firm to...Ch. 2 - 24. A piece of wire is to be bent in the form of a...Ch. 2 - 25. Repeat Programming Exercise 24, but the wire...Ch. 2 - 26. A room has one door, two windows, and a...Ch. 2 - Prob. 27PECh. 2 - 28. In an elementary school, a mixture of equal...Ch. 2 - 29. A contractor orders, say, 30 cubic yards of...
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education