COMP122: Week 2 - Variable Assignments, Conditional Logic, and Control Structures
- Information Technology
- DeVry University
- 5 pages
- Shared May 2025
A homework assignment covering variable assignments, conditional logic, and control structures in C++.
Preview 2 of 5 pages
See the first 2 pages exactly as they appear in the document.
Page 1 Read page 1 as text
1 COMP122: Week 2 - Variable Assignments, Conditional Logic, and Control Structures COMP122 Week 2 Homework Complete the following problems. 1. Suppose you are given the following variable declarations: int x, y; char ch; What values (if any) are assigned to x, y, and ch after each of these statements execute? Assume that the input to each statement is the same : 5 28 36 a. cin >> x >> y >> ch; b. cin >> ch >> x >> y; c. cin >> x >> ch >> y; d. cin >> x >> y; cin.get(ch); • (a) x = 5 , y = 28 , ch = '3' • (b) x = 28 , y = 36 , ch = '5' • (c) x = 5 , y = 36 , ch = 28 (undefined behavior) • (d) x = 5 , y = 28 , ch = ' \ n' 2. Suppose you are given the following variable declarations: int x, y; char ch; What values (if any) are assigned to x, y, and ch after each of these statements execute? Assume that the input to each set of statements is as follows: 13 28 D 14 E 98 A B 56 a. cin >> x >> y; cin.ignore(50, ' \ n ' ); cin >> ch; b. cin >> x; cin.ignore(50, ' \ n ' );
Page 2
3 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 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
Solved AssignmentsCOMP122: Introduction to C++ Programming - Week 1 Homework
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.

