Thread: Help!!!!!!!! What Am I Doing Wrong????

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    5

    Angry Help!!!!!!!! What Am I Doing Wrong????

    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;
    	
    	}
    Last edited by Cnote; 05-19-2002 at 09:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM