You are on page 1of 4

//program on function without argument with return value

//programmed by vrushal
#include<iostream.h>
#include<conio.h>
class alfa
{
int x,y;
public:
void getdata();
void display();
};
void alfa::getdata()
{
cout<<"enter 2 numbers"<<endl;
cin>>x>>y;
}
void alfa::display()
{
float z;
z=x*y;
cout<<"product="<<z<<endl;
}
int main()
{
alfa s1;
s1.getdata();
s1.display();
getch();
clrscr();
return(0);
}
//program on function without argumentand no return vallue
//programmed by vrushal
#include<iostream.h>
#include<conio.h>
class sum
{
int a,b;
public:
void getdata();
void display();
};
void sum::getdata()
{
cout<<"enter 2 integer numbers"<<endl;
cin>>a>>b;
}
void sum::display()
{
int c;
c=a+b;
cout<<"sum="<<c<<endl;
}
void main()
{
sum a1;
a1.getdata();
a1.display();
getch();
clrscr();
}
//program on function with argument and no return value
//programmed by vrushal
#include<iostream.h>
#include<conio.h>
class sub
{
int a,b;
public:
void getvalue(int x,int y);
void display();
};
void sub::getvalue(int x,int y)
{
a=x;
b=y;
}
void sub::display()
{
int c;
c=a-b;
cout<<"substraction="<<c<<endl;
}
void main()
{
sub s;
s.getvalue(8,5);
s.display();
getch();
clrscr();
}
//program on function with argument and return value
//programme dby vrushal
#include<iostream.h>
#include<conio.h>
class gamma
{
int x,y;
public:
void getdata(int a,int b);
void display();
};
void gamma::getdata(int a,int b)
{
x=a;
y=b;
}
void gamma::display()
{
int z;
z=x+y;
cout<<"addition="<<z<<endl;
}
int main()
{
gamma s;
s.getdata(5,6);
s.display();
getch();
clrscr();
return(0);
}

You might also like