Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
Home
Welcome
To Programming Page!!!!
All the given programs are thoroughly checked &
debugged and there is full guarantee for each and every program execution.
LAB # 11
Solution # 1
#include<iostream.h>
#include<conio.h>
long factorial(int);
void main(void)
{
clrscr();
int x;
long y;
cout<<"Enter the numbers whose factorial is to e calculated...\n";
cin>>x;
y=factorial(x);
cout<<"Factrorial of "<<x<<"!"<<"="<<y;
getch();
}
long factorial(int x)
{
int fact=1;
for(int i=x;i>0;i--)
fact*=i;
return fact;
}
Solution # 2
#include<iostream.h>
#include<math.h>
#include<conio.h>
class myclass
{
int number;
public:
void input()
{
cout<<"Enter a number=";
cin>>number;
}
void print()
{
cout<<"\n.The value of entered number is="<<number<<endl;
}
double squareroot();
double powerof(int power);
};
double myclass::squareroot()
{
double result;
result=sqrt(number);
return result;
}
void main(void)
{
clrscr();
myclass myclass;
myclass.input();
cout<<"\n Squareroot of entered number is=";
cout<<myclass.squareroot()<<endl;
cout<<"number to power 2 is="<<myclass.powerof(2)<<endl;
getch();
}
double myclass::powerof(int power)
{
double result;
result=pow(number,power);
return result;
}
Solution # 3
#include<iostream.h>
#include<conio.h>
class myclass
{
int num1,num2;
public:
void input()
{
cout<<"Enter two numbers you want="<<endl;
cin>>num1>>num2;
}
int sum();
int product();
};
int myclass::sum()
{
int add=num1+num2;
return add;
}
int myclass::product()
{
int pro=num1*num2;
return pro;
}
void main(void)
{
clrscr();
myclass myclass;
myclass.input();
cout<<"Sum of entered numbers="<<myclass.sum()<<endl;
cout<<"Product of entered numbers="<<myclass.product()<<endl;
getch();
}
LAB # 12
Solution # 2
#include<iostream.h>
#include<conio.h>
class greateroftwo
{
int greater;
int findmax(int i,int j);
public:
void getandcomputemax();
void printmax();
};
int greateroftwo::findmax(int a,int b)
{
if(a>b)
return a;
else
return b;
}
void greateroftwo::getandcomputemax()
{
int c,d;
cout<<"Enter two integers...\n";
cin>>c>>d;
greater=findmax(c,d);
}
void greateroftwo::printmax()
{
cout<<"the greater of two integers is="<<greater<<endl;
}
void main(void)
{
clrscr();
greateroftwo test;
test.getandcomputemax();
test.printmax();
getch();
}
Wanna query about any program or suggestions. Mail us on : -
webmaster@2k1cp.com
©2001.All rights
reserved by
www.2k1cp.com.