100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home

Exam (elaborations)

Solutions for the study guide

 5 views  1 purchase
  • Course
  • Institution

Solutions for the study guide

Preview 4 out of 65  pages

  • May 2, 2023
  • 65
  • 2022/2023
  • Exam (elaborations)
  • Only questions
avatar-seller
COS1511/102/3/2014




Tutorial letter 102/3/2014

Introduction to Programming 1
COS1511

Semesters 1 & 2


School of Computing


IMPORTANT INFORMATION:
This tutorial letter contains the answers to the
exercises in the study guide.

, TUTORIAL MATTER


Up to now you should have received the material listed below. If not, please download it from myUnisa
immediately (see below) and also contact the Department of Despatch by sending a sms including your query and
student number to 43579, or email info@unisa.ac.za.

Study Guide

DISK 2014 (with software )

Tutorial letters
COSALLF/301/4/2014
General information concerning the School and study at Unisa

COS1511/101/3/2014

Information about COS1511

Assignments

COS1511/102/3/2014 (this letter)

Please note the following

 For e-mail, use the module address namely cos1511-14-S1@unisa.ac.za if you are registered for the first
semester and cos1511-14-S2@unisa.ac.za if you are registered for the second semester.

 Web addresses for downloading of tutorial matter
my.unisa.ac.za

 You need AT LEAST 8 hours study time per week for this module.

Other contact numbers (include your student number in your enquiry)

 For enquiries about registration, send a sms to 43578
 To contact the assignment or examination section, send a sms to 43584
 If you do not receive your study material, send a sms to 43579
 For problems with myUnisa, send a sms to 43582
 For academic queries in the School of Computing, email the lecturer – see myUnisa.
 For any non-academic query you may also send and email to info@unisa.ac.za



Afrikaanssprekende studente: Studiemateriaal vir COS1511 is slegs in Engels beskikbaar. As enigiets
onduidelik is, is u baie welkom om ons te kontak.




Your programs need not be identical to ours. It is, however, important that your programs yield the correct results
(thus extensive testing is essential) and that you use good programming style as explained in the Study Guide. You
should, for example,
 use meaningful names for variables, constants, functions, etc,
 indent your code correctly,
 include comments,
 declare constants where appropriate,
 avoid the use of global variables,
 use the correct types of functions as well as
 the correct types of parameters.



2

, COS1511/102

LESSON 1

Exercise 1.1

We repeat the program here:
#include <iostream>
using namespace std;
int main( )
{ cout << "Hello world"; return 0; }

Descriptive Comment:

There is no descriptive comment.
StandardHeaderFile:

iostream

StatementSequence:

cout << "Hello world"; return 0;

Exercise 1.2

//A poem
#include <iostream>
using namespace std;
int main( )
{
cout << "Twinkle, twinkle, little bat!" << endl;
cout << "How I wonder what you're at?" << endl;
cout << "Up above the world you fly," << endl;
cout << "Like a tea-tray in the sky." << endl;

return 0;
}

LESSON 2

Exercise 2.1

(i) (() + ())

| |

16 + 11

|

27



(ii) ((-5 + -4) - -3)

|

-9 - -3

|
-6




3

, (iii) (((6 * 7) / 8) * 9)

|

42 / 8 * 9

|

5 * 9
|

45



(iv) ((1 - 2) + (() * 5))

| |

-1 + 0 * 5

|

-1 + 0

|

-1



(v) ((-1 + (23 / -4)) + 56)
|

-1 + -5 + 56

|
-6 + 56

|

50

Exercise 2.2

//Lesson 2 Exercise 2.2
//display number of seconds in a minute, hour, day and year
#include <iostream>
using namespace std;
int main()
{
cout << "The are 60 seconds in a minute." << endl;
cout << "The are " << 60 * 60 << " seconds in an hour." << endl;
cout << "The are " << 60 * 60 * 24 << " seconds in a day." << endl;
cout << "The are " << 60 * 60 * 24 * 365 << " seconds in a year." << endl;
return 0;
}

Exercise 2.3

//Lesson 2 Exercise 2.3
#include <iostream>
using namespace std;

int main( )
{
cout << "The remainder of 234 divided by 13 is ";

4

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller thapelolebea. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $0.00. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

56326 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
Free  1x  sold
  • (0)