Addition Program-Programming For Engineers II-Quiz Solution, Exercises of Programming for Engineers

Sir Prachur Sharma took this quiz in class of Programming for Engineers course at Bhagwant University Rajasthan. It includes: Addition, Program, Display, Sum, Integers, Object-oriented, Programming, Constructor, Member, Function

Typology: Exercises

2011/2012

Uploaded on 07/25/2012

anasuya
anasuya 🇮🇳

4

(9)

85 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Quiz-1
Solution
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Addition Program-Programming For Engineers II-Quiz Solution and more Exercises Programming for Engineers in PDF only on Docsity!

Quiz-

Solution

  1. Write an addition program that displays the sum of two integers entered by the user in Object Oriented Programming. class myCal { public: int a,b; int sum() { return a+b; } };

Constructor

  • A constructor is a special member

function that has the same name as

the class. Its purpose is to ensure

that each data member is set to

sensible initial values.

Function

  • A function belonging to a class is called a member function.
  • In a class, you provide one or more member functions that are designed to perform the class's tasks.
  • For example, a class that represents a bank account might contain one member function to deposit money into the account, another to withdraw money from the account and a third to inquire what the current account balance is.