Home Articles C program Write a main function to create objects of DISTANCE class. Input two...

Write a main function to create objects of DISTANCE class. Input two distances and output the sum.



AIM: Write a c++ main function to create objects of distance class then input two distances and output the sum.


Develop a class to measure distance as feet (should be int), inches (should be float). Include member functions to set and get attributes. Include constructors. Develop functions to add two distances.


using namespace std;
class dist
   int feet,inch,x,y,z;
   void input()
      cout<<“enter feet and inches:”<<“\n”;
   void show()
      cout<<“The distance is “;
      cout<<feet<<” feet “<<inch<<” inch\n”;
   void sum(dist x,dist y)
int main()
   dist x,y,z;

Enter feet and inches:
6     3
Enter feet and inches:
3     11
The distance is: 10 feet and 2 inches

JNTUK CSE R16 1-2 Computer Lab Exercise

Here we give all the list of programs which is following JAWAHARLAL NAHRU TECHNOLOGICAL UNIVERSITY, KAKINADA’s R16 Syllabus.

Here we provide Little Bit Introduction and SOURCE CODE for each and every program. Click here for JNTUK CSE R16 1-2 Computer Lab Exercise

Back to Programs.

Basic C programs

Basic c programs for Computer Science Engineering , Information Technology, Master of Computer Applications and Bachelor of Science students.

Here basic c programs for practicing in LAB for CSE, MCA, IT and BSC students.

Practicing Lab C Language basics  for CSE, MCA, IT, BSc students.

Click here for Basic C programs

C language

C language is used to mathematical, business and scientific environments. Every language supports some pre-defined functions and keywords. Using those functions and keywords we can write any type of program statements. C language is one of most popular language in today’s programming language. A program is a group of statements or set of instructions. If we want to perform some task we can write some statements based on that find out the result.

Click here full Article on C Language. 

1th biology
Get Multiple Choice Questions and Answers in 11th biology with detailed explanations for preparation of NEET 2022 exams, CBSE exams, State Board exams and Competitive exams of RRB, RRBNTPC, Bank PO’s, CET 2022, B.ed exams, etc. Find out Unit wise online test series in 11th class biology.
Click here for MCQ’s in 11th biology
10th Maths
10th Maths MCQ’s are useful for preparation of CBSE or NCERT exams. Mockhub.in provide Multiple choice questions and answers in 10th Maths. online Mock tests in 10th Maths are useful as a self assessment practice tests before going to final exams. Find out Chapter or unit wise MCQ’s in 10th maths. Practising Multiple Choice Questions or Objective Questions will surely help the students in their preparation for the examination.
Objective Questions are solved with a detailed explanation i.e., we have solved all the question with step by step solutions. 10th Maths list comprises all the chapter wise questions and answers with explanations. 
Click here for 10th Maths MCQ’s.
class 8 maths chapter 14 

mensuration.in provides exercises and solutions for class 8 maths chapter 14

Click here for NCERT solutions for class 8 maths chapter 14