Is this correct? Please advise. Del
*******************************Actual Code*********************************
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cmath>
int biggest(const int, const int, const int);
int gcd(const int, const int);
void addBlanks(){};
double round(const double);
int main() {
rand();
srand(time(0));
time(0);
int x, y, z, randOut, srandOut;
cout << "Enter three integers. " << endl;
cin >> x >> y >> z;
cout << "The biggest of " << x << "," << y << ", and " << z << "is " << biggest(x,y,z) << endl;
cout << "The greatest comon divisor of " << x << " and " << y << " is " << gcd(x,y) << endl;
cout << randOut << " is a random number. " << endl;
cout << srandOut << " is a seeded random number. " << endl;
cout << "The rounded number is " << round(floatNum) << endl;
return 0;
}
int biggest(const int x, const int y, const int z) {
int size;
if((x < size) && (y < size) && (z < size))
return size;
}
int gcd(const int x, const int y) {
int remainder = x % y;
if(remainder != 0)
return gcd(remainder, x);
return x;
}
void addBlanks() {
//generate random #, print digits seperated by 5 spaces
double firstDigit = digit;
for(int digit = 4; digit >= 0; digit--)
cout << firstDigit << " ";
return;
}
double round(const double floatNum) {
//round parameter to the nearest int
floor(floatNum);
pow(floatNum,);
}
**************************************************************************************
output:
lab4.cpp: In function `double round(double)':
lab4.cpp:67: parse error before `)'
I am not sure on addBlanks() and double round()...please advise.
Description of the problem below:
*************************************************************************************
PART I.
Write function definitions for the following prototypes:
int biggest(const int, const int, const int );
// Returns the largest of three integers.
int GCD( const int, const int );
// returns the greatest common divisor (GCD) of two integers, where GCD is the largest integer that divides both of them evenly.
void addBlanks ( );
/* produce a random integer between 1 and 32767 and print it as a series of digits, where each digit is separated by a space; e.g. 4562 should be printed as: 4 5 6 2 (text 3.25(c) pg 244)*/
PART II.
Write the prototype, definition and call for a function that will take a local double from main and round it to its closest integer value; e.g. 3.45 will become 3.00, and any number >= 3.5 will become 4.00. See pg. 242 Exercise 3.13 for help. The function should modify the value of the double in main.
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cmath>
int biggest(const int, const int, const int);
int gcd(const int, const int);
void addBlanks();
double round(const double);
int main() {
rand();
srand(time(0));
time(0);
int x, y, z, randOut, srandOut, floatNum;
cout << "Enter three integers. " << endl;
cin >> x >> y >> z;
cout << "The biggest of " << x << "," << y << ", and " << z << "is " << biggest(x,y,z) << endl;
cout << "The greatest comon divisor of " << x << " and " << y << " is " << gcd(x,y) << endl;
cout << randOut << " is a random number. " << endl;
cout << srandOut << " is a seeded random number. " << endl;
cout << "The rounded number is " << round(floatNum) << endl;
return 0;
}
int biggest(const int &x, const int &y, const int &z){
int max = x ;
if ( y > x ) {
max = y ;
}
if ( z > max ) {
max = z ;
}
return max ;
}
int gcd(const int x, const int y) {
int remainder = x % y;
if(x > y) {
remainder = y;
}
if(remainder != 0)
return gcd(remainder, x);
return x;
}
void addBlanks() {
//generate random #, print digits seperated by 5 spaces
int digit;
double firstDigit = digit;
for(int digit = 4; digit >= 0; digit--)
cout << firstDigit << " ";
return;
}
double round(const double floatNum) {
//round parameter to the nearest int
floor(floatNum);
cout << pow(double floatNum);
}
g++
lab4.cpp: In function `double round(double)':
lab4.cpp:72: parse error before `)'