You are on page 1of 5

AMIT NAGDEV ST XAVIER’S COLLEGE 19-BCA-172

1.Program to calculate area of square,rectangleand circle

#include<conio.h>
#include<iostream.h>
#include<math.h>
#define PI 3.14
void area(float);//for circle
void area(int,int);//for rectangle
void area();//for square
void main()
{
float radius;
clrscr();
int length,breadth;
cout<<"Enter the VAlue of radius:";
cin>>radius;
cout<<"Enter the value of length:";
cin>>length;
cout<<"Enter the value of Breadth:";
cin>>breadth;
area();//for square
area(radius);//for circle
area(length,breadth);//for rectangle
getch();
}

void area(float r)
{
cout<<"\nArea Of Circle Is:"<<PI*pow(r,2);
getch();
}
void area(int a,int b)
{
cout<<"\nArea Of Rectangle Is:"<<a*b;
getch();
}
void area()
{
int s;
cout<<"Enter the Side Of Square:";
cin>>s;
cout<<"OUTPUT:";
cout<<"\nArea of Square:"<<s*s;
getch();
}

OOCP(practical) BCA-3507L
AMIT NAGDEV ST XAVIER’S COLLEGE 19-BCA-172

2.Program of function overloading and default arguments in various circumstances

#include<iostream.h>
#include<conio.h>
void display(float=0.0);
void display(int=3,int=2);
void display(char* ="Amit");
char * name;
void main()
{
float y=0.1;
clrscr();
display(65);//Call for func2
display("Nikhil"); //Call for func3
display(y);//Call for func1
getch();
}
void display(float y)
{
cout<<"Hello this is 1st program";
y=y+1;
getch();
}
void display(int m,int n)
{
cout<<m+n<<"\n";

OOCP(practical) BCA-3507L
AMIT NAGDEV ST XAVIER’S COLLEGE 19-BCA-172

getch();
}
void display(char* name)
{
cout<<"Name is:"<<name<<"\n";
getch();
}

3. Program to rasie number n times using default argument

#include<iostream.h>
#include<conio.h>
#include<process.h>
double power(double,int=2);
void main()
{
double m,k;
int n;
char ch;
clrscr();
cout<<"Enter the value:";
cin>>m;
cout<<"Want to use default Value of n:";
cout<<"Y(yes) Or N(no):";
cin>>ch;
if(ch=='Y' || ch=='y')
{
k=power(m);
}
else if(ch=='N' || ch=='n')
{
cout<<"Enter the value of n:";

OOCP(practical) BCA-3507L
AMIT NAGDEV ST XAVIER’S COLLEGE 19-BCA-172

cin>>n;
k=power(m,n);
}
else
{
cout<<"Wrong Value Entered";
exit(0);
}
cout<<"The value is:"<<k;
getch();
}
double power(double m,int n)
{
double j=1;
int i;
for(i=0;i<n;i++)
{
j=j*m;
}
return j;
}

OOCP(practical) BCA-3507L
AMIT NAGDEV ST XAVIER’S COLLEGE 19-BCA-172

OOCP(practical) BCA-3507L

You might also like