question in function ?

find the Greatest Common Divisor(GCD)between a number X and all positive numbers that are less than it.
you should havethe following:
1- A constant global integer variable to hold the maximum array size.
2-A void function to initialize allarrayelements to one.This function should take an array of integers as a parameterand set the value of all elements to one.
3-A value returning function to calculate the GCD between two integer numbers. This function takes two integer numbers as a parameter and returns the GCDbetweenthem
4-A void function to calculate all the GCDsbetween a number x and all positive integersthat are less than it, and store the result in an arrayof integers, for example the GCDbetween x and 6 will be stored at location 6 in the array and so on.Thisfunction should take the following parameters, an integer value that represents the integer you want to find all its GCDs, andan array of integers to store the value of GCDs in it. Note:Use the function you define in part 3 to calculate GCD
5- A void function to count number of integers that are relatively prime to a number x. This function should take an array of integers that hold the GCD values with all positive integers that are less than x, the value of x, and a reference parameter to return number of relatively prime numbers with x. Note: a number is said to be relatively prime to x, whenthe GCD between this number and x = 1
In the main function you should perform the following
1.Define an array of integers to hold GCDs
2.Call a functionto initialize all arrayelements to one.
3.Ask the user to insert the integer number you want to find all the GCDs between it and the numbers less than it. You should validate that the inserted number by the used is a positive integer number that is less than the maximum array size, if it is not then set it to maximum array size
4.Call the function to calculate all GCDs between the previous number and all the positive integers less than it.
What is the question?
Methinks the question is... "will someone do all the work of coding this for me?"
#include <iostream>
#include<string>
using namespace std;


string Replace(string s)
{
for(int i=0;i<s.size();i++)
{
if(s[i] == 'a')
s[i] = '#';
}
return s;
}
void Expand(string str)
{
for(int i=1;i<str.size();i++)
{
str.insert(i,"*");
i++;
}
cout << str << endl;
}

int main()
{
string inputStr;
cout << "Enter a string:" << endl;
getline(cin,inputStr);
inputStr = Replace(inputStr);
Expand(inputStr);

return 0;
}
#include <iostream>
using namespace std;
int main()
{
inputNum:
int Num;
cout << "Enter a Positive Number:" << endl;
cin >> Num;
if(Num < 0)
goto inputNum;
else
if(Num == 0 || Num == 1)
cout << "Result = " << Num << endl;
else
{
float sum = 0;

for(int i = 1;i<=Num;i++)
{
float fact = 1;
for(int k =i; k >=1 ;k--)
{
fact *=k;
}
sum = sum + (i/fact);
}

cout << "Result = " << sum << endl;

}

return 0;
}
Topic archived. No new replies allowed.