0

What is Wrong with my code ❓

include <iostream.h> include <conio.h> class complex { float real,img; public: void assign(float x,float y) { real=x; img=y; } void print() { if(img>=0) cout<<real<<"+"<<img<<"i"; else cout<<real<<img<<"i"; getch(); } }; void add( float a,float b,float c, float d) { float e,f;complex g; e=a+c; f=b+d; g.assign(e,f); g.print(); } void sub( float a,float b,float c, float d) { float e,f;complex g; e=a-c; f=b-d; g.assign(e,f); g.print(); } void mul( float a,float b,float c, float d) { float e,f; complex g; e=a*c-b*d; f=b*c+a*d; g.assign(e,f); g.print(); } void main() { float a,b,c,d; complex x,y,z; clrscr(); cout<<" for complex 1:"; cout<<"real part:"; https://code.sololearn.com/coLFDkeQVjRU/?ref=app

14th Apr 2020, 4:55 PM
Kattar
Kattar - avatar
2 Respuestas
+ 2
Use of non-standard functionality, mostly. <iostream.h> has long been replaced by <iostream>, and <conio.h> is outdated and has never been standard in the first place. The main() function must return an integer too. Moreover, preprocessor directives like include need to start with a # in front of them. Also, all things from the Standard Library are encapsulated within the std namespace, therefore you either have to specify that directly when calling them, e.g. std::cout << ..., std::cin >> ..., etc., or you have to import the namespace, i.e. using namespace std; You can also choose to import only parts of it, e.g. using std::cout; using std::cin; ... https://code.sololearn.com/c3xO4MvJkR62/?ref=app
14th Apr 2020, 5:18 PM
Shadow
Shadow - avatar
+ 1
Thanks for the useless C# tag.
18th Apr 2020, 7:23 AM
Shiro
Shiro - avatar