can you help me its showing 1 error

#include<iostream.h>
#include<conio.h>
#include<math.h>
float area(int,int,int)
{
float arearec(int l,int b);
int l,b,o;
o=l*b;

return o;
}

{
int areasq(int a);
int a1,a;
a1=a*a;

return a1;
}

{
float areatri(float q,float w,float e);
float q,w,e;
int x;
x=sqrt(q(q-w)(q-e)(q-r);

return x;
}
void main()
{ clrscr();
int z,a,a1;
cout<<"\nEnter the length and breadth of the rectangle:\n\n ";
cin>>l>>b;
cout<<"\nAREA IS : "<<o<<endl;
cout<<"----------------------------------------------------------------"<<endl;
cout<<"\nEnter the side of the square:\n\n ";
cin>>a;
cout<<"\nAREA IS : "<<a1<<endl;
cout<<"----------------------------------------------------------------"<<endl;
cout<<"Enter the 3 sides of the triangle :\n\n ";
cin>>q>>w>>e>>r;
cout<<"AREA IS : "<<x<<endl;
getch();
}

Error: <iostream.h> does not exist
Error: <conio.h> does not exist

I count more than 1 error (at least twenty). Copy and paste your error log.
Last edited on
Just one?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream.h> // not <iostream.h>
//#include <conio.h> I am not on Windows and can't compile this
#include<cmath> // <math.h> is meant for C, not C++
float area(int,int,int) // missing parameter names
{
    float arearec(int l,int b); // This is a function declaration, and... there is no matching function
    int l,b,o;
    o=l*b; // YOu haven't initialized l or b yet

    return o; // you haven't done any math!  What are you returning?
}

{ // Missing the function header.  This is code in the global scope, that's not allowed
    int areasq(int a); // Function declaraion... and there is no matching function
    int a1,a;
    a1=a*a; // You haven't initialized a yet

    return a1;
}

{
    float areatri(float q,float w,float e); 
    float q,w,e;
    int x;
    x=sqrt(q(q-w)(q-e)(q-r);

    return x;
}
void main()
{ 
    //clrscr();  windows only
    int z,a,a1;
    cout<<"\nEnter the length and breadth of the rectangle:\n\n ";
    cin>>l>>b;
    cout<<"\nAREA IS : "<<o<<endl;
    cout<<"----------------------------------------------------------------"<<endl;
    cout<<"\nEnter the side of the square:\n\n ";
    cin>>a; 
    cout<<"\nAREA IS : "<<a1<<endl; // you didn't write to al yet.
    cout<<"----------------------------------------------------------------"<<endl;
    cout<<"Enter the 3 sides of the triangle :\n\n ";
    cin>>q>>w>>e>>r; // you haven't defined any of these variables
    cout<<"AREA IS : "<<x<<endl; // x hasn't been defined or driven in main
    //getch(); windows only
}
Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream> 
#include<cmath> 
using namespace std;

float arearect(float p_l, float p_b)
{
    return p_l * p_b;
}

float areasq(float p_side)
{
    return p_side*p_side;
}

float areatri(float p_base, p_height)
{
    return p_base * p_height / 2.0f;
}
void main()
{ 
    float length, breadth, side, tri_height, tri_base;
    cout<<"\nEnter the length and breadth of the rectangle:\n\n ";
    cin>>length>>breadth;
    cout<<"\nAREA IS : "<< arearect(length, breadth) <<endl;
    cout<<"----------------------------------------------------------------"<<endl;
    cout<<"\nEnter the side of the square:\n\n ";
    cin>>side; 
    cout<<"\nAREA IS : "<< areasq(side) <<endl;
    cout<<"----------------------------------------------------------------"<<endl;
    cout<<"Enter the 3 sides of the triangle :\n\n ";
    cin>>tri_height >> tri_base;
    cout<<"AREA IS : "<< areatri(tri_height,tri_base) <<endl; 
}

Last edited on
guys im using turbo c++ and it doenot show any error whil i write <iostream.h>

but thnx anyway :D
oh and @stewbond

one question for display the values do i have to inistialize the variables in void main and also in the function ?
thnx @stew bond its working now after some minor changes to ur code

cheers
Variables declared in main are only available in main.
Variables declared in a function are only available in that function.

To send data from main to a function, you pass it as a parameter
To send data from a function back to main, you return a value.
Topic archived. No new replies allowed.