Question

15. Determine the output of th ollowing Ct+ code? int num346, sum 0; do wA sum-sum + num % 10; num = num / 10; cout < sum endl; while (num> e); rmine the output produced by the following code fragment? int i 11; i 1 i 4)10 9 cout << i << . i+t; 13 cout << endl;

Please show all steps for #15 and #16 neatly.

Thank you so much in advance!

Will rate thumbs up for correct answer ! ?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

15.

Output

6
10
13

Explanation

It is to sum all the digits in num

Each time adding last digit of num to sum

Removing last digit of the num

Doing above as long as digits are in n

16.

Output

11 8 5 2

Explanation

Starting from 11

each time decrementing i by 4 in the for line each time incrementing by 1 in the loop

Together, decrementing by 3

11 - 3 = 8

8 - 3 = 5

5 - 3 = 2

Add a comment
Know the answer?
Add Answer to:
Please show all steps for #15 and #16 neatly. Thank you so much in advance! Will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me solve the following. Thank you in advance :) Answer the following five questions...

    Please help me solve the following. Thank you in advance :) Answer the following five questions related to code output (Q2 i through m) What is the output of the following C+ coaer int numl; int num2; int *p = &num1 ; p = &num2 ; *p 25; num1 num2 + 6; p = &num! ; num2 = 73; *p = 47; cout << *p << " "<< numl <<""<< num2 << endl; What is the output of the following...

  • Class: C++ Final Exam Dates Multiple Choice Identify the choice thar best completes the statement or...

    Class: C++ Final Exam Dates Multiple Choice Identify the choice thar best completes the statement or answer the question N 1. In s tructures, the computer repeats particular statements a certain number of times depending on some condition(s) a. looping C. selection b. branching d. sequence 2. What is the output of the following CH code? count = 1; num - 25; while (count < 25) numnum - 1: count++; cout << count << " " << num << endl;...

  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • 4) What is the output if the input istom - Sawyer? #include <iostream> using namespace std;...

    4) What is the output if the input istom - Sawyer? #include <iostream> using namespace std; int main() { string playerName; cout << "Enter name"; cin >> playerName; cout << endl « playerName; return 0; } a. Tom - Sawyer b. Tom Sawyer c. Tom d. Sawyer 5) Which XXX generates "Adam is 30 years old." as the output? #include <iostream> using namespace std; int main() { string name = "Adam"; int age = 30; XXX return 0; } a....

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

  • My professor provided a very vague description of what he wants us to do with the...

    My professor provided a very vague description of what he wants us to do with the example code from the book. I have provided the picture of his description and the code from the book we need to alter. I'm already struggling with this course and I'll probably have to post another question on a different problem I'm stuck on. If you can help it would be highly appreciated. Description Change code for double, string, C-string with appropriate convert constructors...

  • //Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and...

    //Can you write algorithm and comment for the fllowing C++ code. The form of algorithm and comment show in the picture. void cocktailSort(int pData[], int Count) { int iTemp; int ant = 0; int ans = 0; int left = 1; int right = Count - 1; int k=0; if(Count==5&&pData[0]==1&&pData[4]==0) k = 9; int t; do { int i; for (i = right; i >= left; i--) { ant++; if (pData[i]<pData[i - 1]) { iTemp = pData[i]; pData[i] = pData[i...

  • Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. I...

    Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. I have also given the main_problem3.cpp and problem3.h to test. problem3.cpp::: #include "problem3.h" // A function to rotate a matrix mat[][MAX] void rotatematrix(int m, int n, int mat[][MAX]) { // your code here    } Makefile::: all : problem3.o    g++ -o mainp3 # your code here problem3.o : problem3.h problem3.cpp    # your code here clean:    rm -f *.o mainp3 main_problem3.cpp::: #include <iostream>...

  • C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <...

    C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <iostream> #include <fstream> #include <string> using namespace std; int measureElementsPerLine(ifstream& inFile) {    // Add your code here.    string line;    getline(inFile, line);    int sp = 0;    for (int i = 0; i < line.size(); i++)    {        if (line[i] == ' ')            sp++;    }    sp++;    return sp; } int measureLines(ifstream& inFile) {    // Add your code here.    string line;    int n = 0;    while (!inFile.eof())    {        getline(inFile,...

  • please help with the operator overloading lab (intArray) in c++ will provide what it is being...

    please help with the operator overloading lab (intArray) in c++ will provide what it is being required and the code that was given from the book. the code that was provided is below ------------------------------------------------------------------------------------------------------------------------- // iadrv.h #ifndef _IADRV_H #define _IADRV_H #include "intarray.h" int main(); void test1(); void test2(); void test3(); void test4(); void test5(); void test6(); void test7(); void test8(); void test9(); void test10(); void test11(); void test12(); void test13(); void test14(); void test15(); void test16(); void test17(); void test18();...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT