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 <
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:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images