COMP122: Introduction to C++ Programming - Week 1 Homework
- Information Technology
- DeVry University
- 9 pages
- Shared May 2025
A homework assignment introducing C++ programming concepts in the first week of the course.
Preview 3 of 9 pages
See the first 3 pages exactly as they appear in the document.
Page 1 Read page 1 as text
1 COMP122: Introduction to C++ Programming - Week 1 Homework COMP 122 Week 1 Homework Part 1: Complete the following problems . 1. What is machine code? Why is it preferable to write programs in a high level language such as C++? • Machine code is the low - level, binary instructions that a computer’s processor can directly execute. It consists of 0s and 1s and is specific to the computer's architecture. • It is preferable to write programs in high - level languages like C++ because they are easier to read, write, and maintain. High - level languages are more abstract, closer to human language, and allow for faster development compared to working directly with machine code. 2. What does a compiler do? What kinds of errors are reported by a compiler? • A compiler translates source code written in a high - level programming language (like C++) into machine code or an intermediate form (like bytecode). • The compiler reports errors such as syntax errors (e.g., missing semicolons, incorrect variable names) and semantic errors (e.g., type mismatches or incorrect function calls). 3. What does the linker do? The linker combines object files (produced by the compiler) and resolves references between them, including library calls. It produces the final executable program. 4. What is an algorithm? An algorithm is a step - by - step procedure or formula for solving a problem or performing a task. 5. Bob enters a pizza shop and notices there are three different sizes of pizzas available. Sizes are given as the diameter of the pizza in inches. The cost of a pizza is based on the size. Bob would like to know which size of pizza has the lowest cost per square inch. a. Identify the inputs and outputs for this problem. • Inputs : Diameter of the pizza, cost of the pizza. • Output : Pizza size with the lowest cost per square inch. b. Identify the processing needed to convert the inputs to the outputs.
Page 2 Page 3 Read page 3 as text
2 c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output. Part 2: Complete the following problems . 1. Given the following expressions, what value would they have in a C++ program? a. 13 / 4 b. 2 + 12 / 4 c. 21 % 5 d. 3 - 5 % 7 e. 17.0 / 4 f. 8 - 5 * 2.0 g. 14 + 5 % 2 - 3 h. 15.0 + 3.0 / 2.0 a. 13 / 4 Result: 3 Explanation: Integer division truncates the result. b. 2 + 12 / 4 Result: 5 Explanation: Division is done first, so 12 / 4 = 3 , then 2 + 3 = 5 . c. 21 % 5 Result: 1 Explanation: The remainder when 21 is divided by 5 is 1. d. 3 - 5 % 7 Result: 3 - 5 = - 2 Explanation: 5 % 7 is 5 (because 5 is less than 7), so 3 - 5 = - 2 .
6 more pages in the full document
Unlock it once and it stays in your library, ready to chat with or turn into flashcards.
Unlock the full documentMore Information Technology study materials
See all
Solved AssignmentsCOMP122: Week 2 - Variable Assignments, Conditional Logic, and Control Structures
Information Technology
5 pagesMay 2025
Solved AssignmentsCOMP122 Week 1 iLab: Part 1 Test Plan and Results Documentation
Information Technology
6 pagesMay 2025
Solved AssignmentsCOMP122 Week 1 iLab - Introduction to Visual C++.NET and Basic Console Programming
Information Technology
20 pagesMay 2025
Solved AssignmentsCOMP122 Week 2 iLab - Payroll and Right Triangle Program
Information Technology
9 pagesMay 2025
Solved AssignmentsCOMP122: Week 1 iLab - Part 2 Rectangle Area and Perimeter Calculation
Information Technology
9 pagesMay 2025
Exam GuidesTest Bank for Managing and Using Information Systems: A Strategic Approach, 7th Edition (Chapters 1-13)
Information Technology
452 pages149downloadsFeb 2025
Exam GuidesTest Bank for Essentials of MIS, 12th Edition
Information Technology
342 pages146downloadsFeb 2025
Exam GuidesA+ Guide to Hardware, 9th Edition Test Bank
Information Technology
116 pages142downloadsFeb 2025
Study this document with CramX
Once it is in your library, every tool can work from it.

