What is missing?

Oct 30, 2012 at 2:47pm
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.

Oct 30, 2012 at 2:49pm
Under void main, you hae the curely bracket the wrong way around, it should be { not }.
Oct 30, 2012 at 2:51pm
C doesn't have cout and iostream. Use printf and stdio.h instead.
Oct 30, 2012 at 2:53pm
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 Oct 30, 2012 at 3:12pm
Oct 30, 2012 at 3:02pm
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
Oct 30, 2012 at 3:12pm
Thank you very much I've made this program now.
Oct 30, 2012 at 3:14pm
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.