What is missing?

I want to convert this into C code
int a=1, b=2;
cout<<” a is greater than b”<< a>b;
cout<<”a is less than b”<< a<b;
cout<<” a is equal to b”<< a==b;

I did it as

#include <iostream.h>
#include <conio.h>
void main()
}
int a=1, b=2;
cout<<” a is greater than b”<< a>b;
cout<<”a is less than b”<< a<b;
cout<<” a is equal to b”<< a==b;
getch();
}
Having three problems and as a beginner no idea what to do, plz help.

Under void main, you hae the curely bracket the wrong way around, it should be { not }.
C doesn't have cout and iostream. Use printf and stdio.h instead.
Please always use code tags - the <> button on the right.
Use

1
2
3
4
5
6
int main() {  //main always returns an int

//your code

return 0;  //if all is well
}


You also need some if statements before you do the cout. Calculate first, print later.

Hope all goes well.
Last edited on
It looks like the OP doesn't know the difference between C and C++.

He has cout statements, so presumably he wants to do C++, so:

Use :

1
2
#include <iostream>  //<iostream.h> is deprecated
#include <conio.h> //not needed for the code as it is now 


HTH
Thank you very much I've made this program now.
Ok, so mark it as solved.

Don't forget the code tags for next time :)

Hope all goes well.
Topic archived. No new replies allowed.