I have to write a C++ code that computes the greatest common divisor of two numbers.
When Declaring x, y, temp, remainder as a Integer is this right? Or can someone help me in the right direction.

int x = 0;
    int y = 0;

    if (x < y) then
       
    cout << temp = x; 
	cin >> x = y; 
    cout << y = temp 	
	
	if else remainder = x % y

I assume the numbers are x and y?
You set them to zero and then you do an if
saying if(0<0) then...
Do you think this can work?

First cin x and cin y then call a function say int GCD(x,y) to compute your gcd and cout that. And btw x and y can ONLY be integers! The variable temp is never needed.

I'd suggest you to take a look at the Euclidean Algorithm - I don't post links because there's often an example of implementation which could offer some copy-paste temptation...
... not that you couldn't find'em if you wanted to, it's such a common topic...
I guess it's your responsability to be responsible :)

However, let me suggest you to study the syntax first... because the code you posted is far from correct, syntactically apart from logically.

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.