4th semester start!
S. Maik Programmer.
Programming is way to enjoy of mine. Programing =Changing=ideas. Start 0 to 99!
HaPpy INDEPENDENCE DAY..
68 Happy Birthday.
Today the Finally 2nd Semester exam Done!
(2nd Semester)Spring 2014 Final Exam :P
Not Fully Prepared! But still Hoped!
Learning | Innovation | Excellence
To find the mean value of a given number using friend function.
ALGORITHM:
STEP 1: Start the program.
STEP 2: Declare the class name as Base with data members and member functions.
STEP 3: The function get() is used to read the 2 inputs from the user.
STEP 4: Declare the friend function mean(base ob) inside the class.
STEP 5: Outside the class to define the friend function and do the following.
STEP 6: Return the mean value (ob.val1+ob.val2)/2 as a float.
STEP 7: Stop the program.
PROGRAM:
class base
{
int val1,val2;
public:
void get()
{
coutval1>>val2;
}
friend float mean(base ob);
};
float mean(base ob)
{
return float(ob.val1+ob.val2)/2;
}
void main()
{
clrscr();
base obj;
obj.get();
cout
1st quarter Mid Done!
"1at May"
"Labour's Day"
Class 0f
using namespace std;
class Circle
{
private:
float radius;
public:
void get_radius(float r)
{
radius=r;
}
void area()
{
cout
Class of
using namespace std;
class Book
{
private:
int BookID,pages;
float Price;
public:
void get()
{
coutBookID;
coutpages;
coutPrice;
}
void show()
{
cout
Three data members store three marks!
Class 0f
using namespace std;
class Marks
{
private:
int a,b,c;
public:
void in()
{
couta>>b>>c;
}
int sum()
{
return a+b+c;
}
int avg()
{
return (a+b+c)/3.0;
}
};
int main()
{
Marks m;
int s;
float a;
m.in();
s=m.sum();
a=m.avg();
cout
Click here to claim your Sponsored Listing.
Location
Category
Website
Address
Sialkot
51310