The code is not producing this correct output. What could be wrong?    Multiply.cpp: In function ‘int main()’: Multiply.cpp:13:12: error: expected initializer before numeric constant int by 10; // Stores the number multiplied by 10 ^~ Multiply.cpp:14:12: error: expected initializer before numeric constant int by 2; // Stores the number multiplied by 2 ^ Multiply.cpp:27:8: error: ‘byTwo’ was not declared in this scope byTwo=counter*2; //storing the multiplied value in byTwo ^~~~~ Multiply.cpp:29:7: error: ‘byTen’ was not declared in this scope byTen=counter*10; //storing the multiplied value in byTen ^~~~~ Multiply.cpp:15:14: warning: unused variable ‘NUM_LOOPS’ [-Wunused-variable] const int NUM_LOOPS = 10; // Constant used to control loop ^~~~~~~~~ /bin/bash: line 4: ./a.out: No such file or directory   #include using namespace std; int main(){     string head1 = "Number: ";     string head2 = "Multiplied by 2: ";     string head3 = "Multiplied by 10: ";            int numberCounter;           // Numbers 0 through 10     int byTen;           // Stores the number multiplied by 10     int byTwo;             // Stores the number multiplied by 2     const int NUM_LOOPS = 10;    // Constant used to control loop       // This is the work done in the housekeeping() function     cout << "0 through 10 multiplied by 2 and by 10." << endl;          // This is the work done in the detailLoop() function     cout<< head1 << head2 << head3 <

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The code is not producing this correct output. What could be wrong? 

 

Multiply.cpp: In function ‘int main()’:
Multiply.cpp:13:12: error: expected initializer before numeric constant
int by 10; // Stores the number multiplied by 10
^~
Multiply.cpp:14:12: error: expected initializer before numeric constant
int by 2; // Stores the number multiplied by 2
^
Multiply.cpp:27:8: error: ‘byTwo’ was not declared in this scope
byTwo=counter*2; //storing the multiplied value in byTwo
^~~~~
Multiply.cpp:29:7: error: ‘byTen’ was not declared in this scope
byTen=counter*10; //storing the multiplied value in byTen
^~~~~
Multiply.cpp:15:14: warning: unused variable ‘NUM_LOOPS’ [-Wunused-variable]
const int NUM_LOOPS = 10; // Constant used to control loop
^~~~~~~~~
/bin/bash: line 4: ./a.out: No such file or directory

 

#include<iostream>

using namespace std;

int main(){

    string head1 = "Number: ";
    string head2 = "Multiplied by 2: ";
    string head3 = "Multiplied by 10: ";       
    int numberCounter;           // Numbers 0 through 10
    int byTen;           // Stores the number multiplied by 10
    int byTwo;             // Stores the number multiplied by 2
    const int NUM_LOOPS = 10;    // Constant used to control loop
 
    // This is the work done in the housekeeping() function
    cout << "0 through 10 multiplied by 2 and by 10." << endl;
    
    // This is the work done in the detailLoop() function
    cout<< head1 << head2 << head3 <<endl; 
    // Write while loop here 
    int counter=0;
    while(counter<=10){         //checking whether counter lies in range
       byTwo=counter*2;         //storing the multiplied value in byTwo
       byTen=counter*10;        //storing the multiplied value in byTen
       cout << counter <<"\t" << byTwo << "\t\t " <<byTen<<endl;
       
       //incrementing counter in every iteration
       counter++; 
    }
   
    // This is the work done in the endOfJob() function
    return 0;

}

 

Correct Ouput:

Number: 0
Multiplied by 2: 0
Multiplied by 10: 0
Number: 1
Multiplied by 2: 2
Multiplied by 10: 10
Number: 2
Multiplied by 2: 4
Multiplied by 10: 20
Number: 3
Multiplied by 2: 6
Multiplied by 10: 30
Number: 4
Multiplied by 2: 8
Multiplied by 10: 40
Number: 5
Multiplied by 2: 10
Multiplied by 10: 50
Number: 6
Multiplied by 2: 12
Multiplied by 10: 60
Number: 7
Multiplied by 2: 14
Multiplied by 10: 70
Number: 8
Multiplied by 2: 16
Multiplied by 10: 80
Number: 9
Multiplied by 2: 18
Multiplied by 10: 90
Number: 10
Multiplied by 2: 20
Multiplied by 10: 100
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY