Question

Subject: Object Oriented Programming (OOP)

Q3: Question # 3 [20] Will the following code compile? If it does not, state the errors. If it does compile, write the output

04: Question #4 [7+7+6 = 20) a. Will the following code compile? If it does not, state the errors. If it does compile, write

b. Will the following code compile? If it does not, state the errors. If it does compile, write the output #include <iostream

Please kindly solve the above two questions as soon as possible would be really grateful to a quick solution. would give a thumbs up.

Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 3 :

The question compiles successfully.

Output :

In int printData 10 In float printData 10 In long printData 20

Execution :

7 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 5 void printData(long i) //for long 6-{ cout<<In long pri

Question 4 :

a.

The code will compile with an error that _getch() was not declared in this scope.Compilation failed due to following error(s). main.cpp: In function int main(): main.cpp:18:12: error: _getch was not dec

But if we remove _getch() then the output will be :

А B D End ofprogram

Execution:

1 2 #include <iostream> 3 4 using namespace std; 5 6 int maino 7- 8 char i, j, k; 9 i = A; 10 cout<<i<<endl; //print i i.e

b.

The code will compile with an error that _getch() was not declared in this scope.

Compilation failed due to following error(s). main.cpp: In function int main(): main.cpp:18:12: error: _getch was not dec

But if we remove _getch() then the output will be :

65 66 68 End of program

Execution :

1 #include <iostream> 4 7 3 using namespace std; 5 int main() 6- { int i, j, k; 8 i A; //ASCII value of A is 65 so it get s

c.

Code :

#include<iostream>
using namespace std;

int main()
{
  
cout<<"One Double Quote : \""<<endl; //print single double quote
cout<<"Two Double QUote : \"\""<<endl; //print two double quote
cout<<"Backslash : \\"<<endl; //print backslash
  
return 0;
}

Output :

One Double Quote : Two Double Quote Backslash : 1

Execution :

Add a comment
Know the answer?
Add Answer to:
Subject: Object Oriented Programming (OOP) Please kindly solve the above two questions as soon as possible...
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
  • 15.6: Fix the code to print the count from 1 to x (to loop x times)...

    15.6: Fix the code to print the count from 1 to x (to loop x times) #include <iostream> // include the header file using namespace std; void count(int x){    for(int i=1; i<=x; i++){ cout<<x; } } int main(){    int x,i;    cin >> x; count(x);    return 0; } 15.7 Fix the nested for loops to print the count from 1 to x twice, e.g. "12....x12.....x" #include <iostream> // include the header file using namespace std; int main(){...

  • //This program is your final exam. //Please fill in the functions at the bottom of the...

    //This program is your final exam. //Please fill in the functions at the bottom of the file. (evenCount and insertItem) //DO NOT CHANGE ANYTHING ELSE. //main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine //Note that in this case, the list is not sorted and does not need to be. Your goal is to insert the number in the given position. #include <iostream> #include <fstream> using...

  • //This program is your final exam. //Please fill in the functions at the bottom of the...

    //This program is your final exam. //Please fill in the functions at the bottom of the file. (evenCount and insertItem) //DO NOT CHANGE ANYTHING ELSE. //main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine //Note that in this case, the list is not sorted and does not need to be. Your goal is to insert the number in the given position. #include <iostream> #include <fstream> using...

  • KINDLY HELP SOLVE THE C++ SECURE SHELL DRILLS, RUN AND COMPILE THEM TO PERFORM THE TASK PERFECTLY...

    KINDLY HELP SOLVE THE C++ SECURE SHELL DRILLS, RUN AND COMPILE THEM TO PERFORM THE TASK PERFECTLY. THANK YOU. /1 Function: Complete the body of the Read _Kth Num function. #include <iostream> using namespace std; // Read the k'th input value. DO NOT ISSUE A PROMPT // Example: when 3 and inputs are 4 6 8 10 12 the desired value is 8 void Read Kth Num (int k, int & value) tinclude "mainpt60300a.cpp" //Function: Complete the MaxVal function #include...

  • what is the output for the following code? explain the steps. /*#include <iostream> using namespace std;...

    what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...

  • Fix the code to print the "exact" result of the division of a/b (Pass by reference)...

    Fix the code to print the "exact" result of the division of a/b (Pass by reference) #include <iostream> using namespace std; void division (int& a, int& b, int& result) {    result = a/b;    } int main () { float a, b, result;    cin >> a; cin >> b;    division(a, b, result); cout << "result = " << result << endl; return 0; }

  • Directions: Develop a C++ program that can solve any matrix, up to 15 equations with 15...

    Directions: Develop a C++ program that can solve any matrix, up to 15 equations with 15 unknowns. Put the result on the screen as well as write the results to a text file This is what we were given as a hint: /* how to read matrix data file in rows and colloms written by tom tucker 03/26/2018 it uses a string array to read in the first line and then a nested for statement to read in the matrix...

  • I have to type and explain in class each code in every detail filled with //...

    I have to type and explain in class each code in every detail filled with // commentary. Explains how does work in every codes. 1) What does the below print #include <iostream> using namespace std ; int main() {    int var1 = 20 ;    int var2 = 30 ;    int* ptr1 ;    int* ptr2 ;    int* temp ;    ptr1 = &var1 ;    ptr2 = &var2 ;    cout << *ptr1 << endl ;...

  • #include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool...

    #include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool openFile(ifstream &); void readData(ifstream &, int [], int &); void printData(const int [], int); void sum(const int[], int); void removeItem(int[], int &, int); int main() { ifstream inFile; int list[CAP], size = 0; if (!openFile(inFile)) { cout << "Program terminating!! File not found!" << endl; return -1; } //read the data from the file readData(inFile, list, size); inFile.close(); cout << "Data in file:" <<...

  • 2 The following code has some errors. Please point out and correct them (there might be...

    2 The following code has some errors. Please point out and correct them (there might be more than 1 errors). Note: the use of const data member increment and member function print. // This code has some errors. #include using namespace std; class Increment { public: Increment( int c = 0, int i = 0); void addIncrement() const { count -= increment }; void print() const; private: int count; const int increment; }; Increment::Increment(int c, int i) { cout =...

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