(Modify) Rewrite the following programs to conform to good
a. #include
int main(
){
cout <<
“The time has come”
; return 0;}
b. #include
using namespace std;
int main
( ){cout << “Newark is a city\n”;cout <<
“in New Jersey\n”; cout <<
“It is also a city\n”
; cout << “in Delaware\n”
; return 0;}
c. #include
using namespace std;
int main() {cout << Reading a program\n”;cout <<
“is much easier\n”
; cout << “if a standard form for main is used\n”
; cout
<<“and each statement is written\n”;cout
<< “on a line by itself\n”
; return 0;}
d. #include
using namespace std;
int main
( ){ cout << “Every C++ program”
; cout
<<“\nmust have one and only one”
;
cout << “main function”
;
cout <<
“\n The escape sequence of characters”)
; cout <<
“\nfor a newline can be placed anywhere”
; cout
<<“\n in the message passed to cout”
; return 0;}
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
C++ for Engineers and Scientists
- (C PROGRAMMING ONLY!) 6. Teaching the Dog To Sitby CodeChum Admin Ever since I was a kid, I've always wanted to see a dog sit because it's so cute ? Let's create a function that lets a dog sit! Instructions: In the code editor, you are provided with the definition of a struct Dog. This struct needs an integer value for its age. Furthermore, in the main, a Dog is already created for you and is passed to a call to a function, sit().Your task is to declare and define the function sit() which has the following details:Return type - voidName - sitParameters - 1 DogDescription - prints the message, "Arf arf! My age is <AGE_OF_DOG> and I know how to sit!"Input 1. The age of the Dog Output Enter age of Dog: 3Arf arf! My age is 3 and I know how to sit!arrow_forward(C PROGRAMMING ONLY) 3. From Person to Peopleby CodeChum Admin Now that we have created a Person, it's time to create more Person and this tech universe shall be filled with people! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons.Your task is to ask the user for the values of the age and gender of these Persons.Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one.Input 1. A series of ages and genders of the 5 Persons Output Person #1Enter Person's age: 24Enter Person's gender: M Person #2Enter Person's·age: 21Enter Person's gender: F Person #3Enter Person's age: 22Enter Person's gender: F Person #4Enter Person's age: 60Enter…arrow_forwardthe following 12. (Greatest Common Divisor) Given two integers x and recursive definition determines the greatest common divisor of x and y, written gcd(x,y): Y, if y = 0 gcd(x, y) = %3D gcd(y, x%y) if yチ0 Note: In this definition, % is the mod operator. write a recursive function, gcd, that takes as parameters two integers and returns the greatest common divisor of the numbers. Also, write a pro- gram to test your function.arrow_forward
- (Rounding Numbers) Function floor may be used to round a number to a specific decimalplace. The statementy = floor(x * 10 + .5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + .5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Writea program that defines four functions to round a number x in various waysa) roundToInteger(number)b) roundToTenths(number)c) roundToHundreths(number)d) roundToThousandths(number)For each value read, your program should print the original value, the number rounded to thenearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth, and the number rounded to the nearest thousandth.arrow_forwardUSE C++ programming language 1) State whether the following declarations are valid or invalid. Give reasons for the invalid declarations and draw memory layout for the valid declarations i)int var = 25;int *ptr = &var; ii)int var = 30;int* ptr = var;arrow_forward(ONLY USE JAVA ARRAYS) USE JAVA LANGUAGE ONLY Telephone Directory SystemA telephone book system, also known as a telephone directory, telephone address book, or Phone book, isa listing of telephone subscribers in a geographical area or subscribers to services provided by theorganization that publishes the directory. Its purpose is to allow the telephone number of a subscriberidentified by name and address to be found. The features of telephone book system are mainly related toadding, listing, searching, sorting, modifying and deleting telephone directory-related records. Here weare going to create a java application for Telephone directory system.• Contact module: This module allows the user to enter all the details like auto-generated ID,name, phone number, city, country, residential address, website, mobile, company, and date ofbirth• Insert record: In this module, all the details regarding contacts are inserted.• Delete record: In this module, the records with a specific id or name…arrow_forward
- Q1) Suppose we have data about students of a class i.e. name, addresses, date of birth, GPA and courses of study. This information is related to only a single entity i.e. student. Which type of programming method you will use to initialize and display this information. Explain with a program. Needed code in C++arrow_forwardc programming not c++arrow_forward2. (Functions with C string parameters) Write a program in C that uses the function, MakeSentenceExcited() to replace any period (full stop or comma) with an exclamation point. If the input string is: I told my computer I needed a break. It replied "I am sorry, I'm not programmed for that function." The output will be: I told my computer I needed a break! It replied "I am sorry! I'm not programmed for that function!" Assign a string size of 200 or above. Use "fgets()" to take the string input. Don't forget to include the string header file. Hint: A very similar example 3 problem is given in the lab slide. Try to follow that example.arrow_forward
- (10 points) Filled out the following table regarding C++ STL and corresponding data structures that implement the STL class. C++ STL vector map set priority_queue unordered map unordered set Data Structure arrayarrow_forward(USING PYTHON) create a function create employee_objects that takes a list of data as input and returns back a list with each element as an object that belongs to class Employee def create employee_objects (data): #start of code # end of code employees_list = create employee_objects (employees_data) Expected output: 29arrow_forwardQ1)There are 10 boxes of apples arranged in a row, assume the values have been stored in an arrayaryBox. Use C code to write a C program segment to find out which box is having the most number of applesas compared to other boxes. A sample output is as follow:Box number 5 contains the most number of apple.[Note: You need to declare all the necessary variables and use an efficient way to representthe data as well as solving the problem]arrow_forward
- 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