Hi, Everybody.
After compiling below program i am getting error" prg2(distance with error),Please help me to resolve.
Thank you

#include<iostream.h>
#include<conio.h>
struct distance
{
int feet;
int inches;
};
distance length1,length2;
void prnsum(int distance11,distance12);
int main()
{
clrscr();
int distance,z;
cout<<"Enter length1:"<<"\n";
cout<<"Feet:";
cin>>length1.feet;
cout<<"\n"<<"Inches:";
cin>>length1.inches;
cout<<"\n"<<"\n"
    <<"Enter length2:"<<"\n";
cout<<"Feet:";
cin>>length2.feet;
cout<<"\n"<<"Inches:";
cin>>length2.inches;
prnsum(length1,length2);
return 0;
cin>>z;
}
void prnsum(int distance11,distance12)
{
distance 13;
13.feet=11.feet+12.feet+(11.inches+12.inches)/12;
13.inches=(11.inches+12.inches)%12;
cout<<"\n"<<"\n";
cout<<"Total Feet:"<<13.feet<<"\n";
cout<<"Total Inches:"<<13.inches;
return;
}
Member Avatar for iamthwee

Well #include<iostream.h> That should be #include <iostream> and then you can use the using namespace std; or std:: prefixes with it.


And conio.h is non-standard and should ideally be avoided. cin.get(); can be used to pause the program if you're using getch().

I think you need to look at your notes again about structs, it is not quite right.
http://www.fredosaurus.com/notes-cpp/structs/structs.html
http://www.cplusplus.com/doc/tutorial/structures.html

Also using distance 13; i.e a number as your struct declaration seems a bit odd. I don't know if it is legal.

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.