#include
#include
int gcd (int , int );
void main ()
{
	int m, n;
	cout<<" Enter first integer:";
	cin >>m>>endl;
	cout<<" Enter second integer:";
	cin >>n>>endl;
	cout<<m<<"&"<<n<<" The GCD is:"<<gcd(m,n)<<endl;
}
                int gcd (int x, int y)
{
	if(y==0)
		return x;
	else
		return gcd(y,x%y);
}

Recommended Answers

All 4 Replies

You need to list header file names, not just the preprossor command include.

You may need to include a statement regarding namespace std depending on your compiler.

main() should always have return type int, not void.

I've never tried to output a string literal equal to this: "&". If that's line 9, then you may have to precede the & by a \ to get it to show.

Posting your error messages indicating a problem on lines 9 and 11 would be helpful.

Next time enclose your posted code in code tags, please. There are a number of excellent posters who won't even consider looking at your code if not formatted correctly for this board.

My two headers are

#include<stdio.h>
#include<stdlib.h>

Cpp1.cpp(9) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class ostream &(__cdecl *)(class ostream &)' (or there is no acceptable conversion)
Cpp1.cpp(11) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class ostream &(__cdecl *)(class ostream &)' (or there is no acceptable conversion)
Error executing cl.exe.

tks for helping

You don't use endl; after cin you use it after cout . cin is used for input. Please use code tags as well

Look at the errors you are getting. They concern the operators << and >> and then read the text after them...ostream. As someone else stated, you are also missing a namespace, or at least the specific portions of the namespace that you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.