Professional Documents
Culture Documents
Roll no: 05
Mca 1st shift
Output:
void main()
{
int s,r,h,r1;
clrscr();
cout<<"Enter side of cube : ";
cin>>s;
volume(s);
void volume(int s)
{
int ans;
ans=s*s*s;
cout<<"The volume of cube = "<<ans<<endl;
}
Output :
}
friend float calculate(salary s)
};
float calculate(salary s)
{
float hra,da,gross;
hra=.6*s.basic_salary;
da=.98*s.basic_salary;
gross=s.basic_salary+s.hra+s.da;
cout<<"\nhra="<<hra;
cout<<"\nda="<<da;
void main()
{
clrscr();
salary s;
s.input();
s.display();
calculate(s);
getch();
}
OUTPUT
#include<iostream.h>
#include<conio.h>
int main()
{
int a,d,sum=0,c;
clrscr();
cout<<"enter number:";
cin>>a;
c=a;
while(a>0)
{
d=a%10;
sum=sum+d*d*d;
a=a/10;
}
if (c==sum)
{
cout<<"armstrong";
}
else
{
cout<<"not armstrong";
}
getch();
}
OUTPUT:
OUTPUT:
OUTPUT:
SOURCE CODE(PALLINDROME):
#include<iostream.h>
#include<conio.h>
#include<string.h>
int main()
{
char n[10],n1[10];
int a;
int no,d,c,rev=0;
clrscr();
cout<<"enter string"<<n1;
cin>>n1;
strcpy(n,n1);
strrev(n1);
a=strcmp(n1,n);
if(a==0)
{
cout<<"string is pallindrome"<<endl;
}
OUTPUT:
OUTPUT:
}
getch();
}
OUTPUT:
#include<iostream.h>
}
};
void main()
{
int ch;
clrscr();
Bank b1;
b1.getdata();
clrscr();
b1.display();
OUTPUT:
OUTPUT:
public:
Meter()
{
}
Meter(int a, int b)
{
met=a;
cm=b;
}
void display()
{
cout<<"Distance is "<<met<<"meters and "<<cm<<"cms.";
}
public:
Feet()
{
}
Feet(int a,int b)
{
ft=a;
in=b;
}
void display()
{
cout<<"\nDistance is "<<ft<<"Feet & "<<in<<"inches.";
}
friend void add_Meter(Meter,Feet);
friend void add_Feet(Meter,Feet);
};
void add_Meter(Meter d1,Feet d2)
OUTPUT:
void main()
{
int a,b,ch;
clrscr();
cout<<"Enter the first number : ";
cin>>a;
cout<<"Enter the second number : ";
cin>>b;
cout<<"\n\nHow would you like to swap the values ?"<<endl;
cout<<"1 : call by value";
cout<<"\n2 : call by reference";
cout<<"\n3 : by using two variables"<<endl;
cin>>ch;
getch();
}
OUTPUT:
Reverse.cpp:
getch();
}
void reverse1()
{
char name[50];
cout<<"Enter name : ";
cin>>name;
int i,l=0;
for(i=0;name[i]!=NULL;i++)
{
l++;
}
for(i=l-1;i>=0;i--)
{
cout<<name[i];
}
cout<<"\t\t";
}
void reverse2()
{
long int no;
int rev;
cin>>no;
while(no>0)
{
rev=no%10;
cout<<rev;
no=no/10;
}
cout<<"\n\n";
}
OUTPUT: