Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help finishing out the code for this program in C++ that I've written so far. I can't figure out how to cout display

image text in transcribed

I need help finishing out the code for this program in C++ that I've written so far. I can't figure out how to cout display "5 + 7 + 8 +9", "0 + 0 + 2 + 9", and "0 + 0 + 1 + 1"

image text in transcribed

Instructions Write a program named digits.cpp that: Prompts the user for a four-digit number Calculates the sum of its digits . . Calculates the sum of the digits of the sum Calculates the sum of the digits Sample Output NOTE: there are two separate sample outputs of the same program below, divided into each box. Please enter a four-digit number: 57894 Sum of the digits: 5 + 7 + 8 + 9 = 29 Sum of the digits of the sum: 0 + 0 + 2 + 9 = 11 Sum of the digits of the sum of the digits of the sum: 0 + 0 + 1 + 1 = 2 File Edit View Git Help Search (Ctrl + Labo2 KR Project Build Debug Test Analyze Tools Extensions Window -- - Debug Debug - XB6 - Local Windows Debugger T Live Share My Benefits Solution Explorer - Eas-* D Search Solution Explorer (Ctrl+;) Solution Lab02" (1 of 1 project) * Labo2 D - References > External Dependencies 2 Header Files Resource Files Source Files D ** digits.cpp digits.cpp - X Lab02 (Global Scope) E//This program will prompt user to insert 4 digits 2 //Then calculate the sum of the digits 3 //Then sum of digits of the sum 4 //Then sum of the digits of the sum of the digits of the sum 5 #include 6 using namespace std; 7 Pint main() 8 { 9 int num, numi, num2, sum, sum1=0, sum2=8; //Define user input, integers and variables 10 cout > num; //User input 12 13 while (num != 0) { 14. sum + (num % 10); 15 num/= 10; 16 17 cout ------ Rebuild All started: Project: Labaz, Configuration: Debug Win32 1>digits.cpp 1>Lab@2. vcxproj -> C:\Users\krhoa\Desktop\Cmpsc121\Labs\Lab82\Debug Laba2.exe ---------- Rebuild All: 1 succeeded, failed, skipped ---------- Solution Explorer Git Changes 33 Properties TABS CRLF -X Error List Output Ready Add to Source Control

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago