Welcome! Log In Create A New Profile


Assignment 2 Question 6

Posted by SkillS4eva 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 2 Question 6
May 17, 2006 02:08PM
I see no one has asked for help or had trouble with Assignment 2 Question 6. Has everyone else completed it no problem and am I just useless???
I can't make heads or tails of it sad smiley [/img]
Re: Assignment 2 Question 6
May 18, 2006 02:53AM
Have a look at section 6.14 in Cohoon and Davidson. The recursive function we needed to write is very similar.
Re: Assignment 2 Question 6
May 18, 2006 02:14PM
* Scratches around for the text book * Dunno if i bought it though... it Was kinda expensive...

confused smiley [/url]
Re: Assignment 2 Question 6
May 18, 2006 04:06PM
Here is the code for the simplest of all the questions.

#include <iostream>
#include <string>
using namespace std;

int gcd(int m,int n) {
if ((m % n) = 0) //evaluates whether m can be divided by n without a remainder then n is the gcd
return n;
return gcd(n,(m % n)); //use the c++ bult in function to return the gcd for u if you read the section on recursive functions you will have known this


int main() {
int m, n;
cout << "Please enter two integers: " << endl;
cin >> m >> n;
cout << " Greatest common divisor for " << m << " / " << " n " <<
" is: " << gcd(m,n) << endl;
return 0;

Please no insult, but gcd you were thought in std 7 or 8 I think can't remember. Now just code it, it is simple.
Re: Assignment 2 Question 6
May 19, 2006 10:01AM
You're probably gonna need to shell out for the textbook at some point. The study guide doesn't cover most of the material, it just tells you what to read in the textbook.

I had never touched C++ before starting COS111 & COS112 this year, and the textbook has been a lifesaver! That and the COS111 study guide.
Re: Assignment 2 Question 6
May 19, 2006 01:26PM
Damn. I didnt purchase the text book. Is it possible to pass the end year exam with just the Study Guide from Unisa?

Thanks Guys
Sorry, only registered users may post in this forum.

Click here to login