I been working on these two projects forever and I have to turn them in tomorrow. I keep receiving errors and now I'm out of answers. One project I received help from someone, but my teacher said the coding was wrong. Please help!
Project 1: You are writing a code to find the greatest common divisior (gcd) Write a recursion function to find the gcd, returns integer with two integer arugmentss n amd m. Use gcd(m,n%m) format. if one of the two integerss is 0, the gcd will be the 2nd integer. tell the user to enter -1 for exiting.
Ok, here are the errors I'm receiving for this code:
error C2146: syntax error : missing ';' before identifier 'cout'
error C2065: 'end1' : undeclared identifier
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int (__cdecl *)(int,int)' (or there is no acceptable conversion)
error C2065: 'm' : undeclared identifier
error C2065: 'n' : undeclared identifier
error C2143: syntax error : missing ';' before '}'
error C2143: syntax error : missing ';' before '<<'
error C2501: 'cout' : missing storage-class or type specifiers
error C2371: 'cout' : redefinition; different basic types (same error for 'cin')
error C2447: missing function header (old-style formal list?)
fatal error C1004: unexpected end of file found
Code:
#include<iostream.h>
int gcd (int n, int m)
{
if (m==0)
return n;
else
return gcd (m,n%m);
}
void main ()
{
int gcd (int n, int m)
cout<<"Enter n,m ?"<<end1;
cout<<"The greatest common divisor gcd"<<end1;
cin>>gcd;
while (m>n)
}
cout<<"Have a Nice Day"<<end1;
cin>>gcd;
{
project 2: Calcukate the average of a series if test scores where the series is dropped. GetValues should ask for five test scores and store them in variables. findlowest should determine which of the five scores if the lowest, return value. CalcAverage should calculate and display the average of the four highest scores.
Code:
#include <iostream.h>
void main ()
{
void Getvalues(); // prototype of function
double Getvalues (double x[]);
int scores, x;
cout<<"Please enter values";
for(x = 0; x <=5; ++x){
cin>>scores [x];
}
void findlowest ()
double findlowest [5];
int lowest = scores[0];
for (x =0; x<= 5; ++x)
if (x<lowest)
scores = x;
else
return scores;
}
void calcaverage ()
double calcaverage [4];
int highest= scores [0];
for (int x = 0; x<=100; ++x);
if (scores < highest)
highest=scores ;
}
cout<<"The average is"<<calcaverage<<end1;
cout<<"Have a nice day"<<calcaverage<<end1;
}