• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 55 pages
Exam (elaborations)

Cos1512_Exam_Pack

Document preview thumbnail
Preview 4 out of 55 pages

JUNE 2017 P2 Page 1 of 6 1 C STRINGS Error Correction If(str!=”STOP” If(strcmp(str,”STOP”); Str = “STOP” Strcpy(str,”STOP”); 2 RECURSION Void CountDown(int num) { If (num = 0) Cout 0 endl; Else { Cout num endl; CountDown(num-1); } } 3 POINTERS 3.1 The problem with this this code fragment is that the code deletes the pointer. Thereafter, the programmer is assigning the value to a pointer that doesn’t point to anything. The results are disastrous. 3.2 Correct the Code 3.2.1 5 : p1 = &x; 6 : p2 = &y; 3.2.2 7: cout *p1 “ “ *p2; 3.2.3 9: 30 3.3 typedef int* myPtr; myPtr = a; int size’; a = new int[size]; 4 DEFINE PRODUCT CLASS Product.h #ifndef PRODUCT_H #define PRODUCT_H #include iostream #include cstdlib #include string #include fstream JUNE 2017 P2 Page 2 of 6 using namespace std; class Product { public: Product(); ~Product(); long getNumber(); void reset(long rID, double rPrice, long rNum); void increaseRetailPrice(float incPercent); friend bool operator ==(const Product &p1, const Product &p2); friend Product operator -- (Product &P); friend istream& operator (istream& ins, Product &P); friend ostream& operator (ostream& outs, const Product &P


Document information

Uploaded on
October 10, 2021
Number of pages
55
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers
$3.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LOVELY01
3.6
(127)
Sold
1015
Followers
881
Items
2321
Last sold
4 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.