0% found this document useful (0 votes)
14 views104 pages

Practical File

The document contains multiple C++ programs written by Prabhat Singh, each with a specific aim such as displaying university information, calculating mathematical operations (addition, maximum, minimum, factorial), and finding areas of geometric shapes. Each program includes functions for the respective calculations and user input prompts. The document showcases various programming concepts including function declarations, loops, and conditional statements.

Uploaded by

shivams0128
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views104 pages

Practical File

The document contains multiple C++ programs written by Prabhat Singh, each with a specific aim such as displaying university information, calculating mathematical operations (addition, maximum, minimum, factorial), and finding areas of geometric shapes. Each program includes functions for the respective calculations and user input prompts. The document showcases various programming concepts including function declarations, loops, and conditional statements.

Uploaded by

shivams0128
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//NAME : Prabhat Singh

//PRN : 2018033800098741
//DATE : 29-01-2021
//SET : 1(P-1)
//AIM : TO DISPLAY SEVEN LINES ABOUT UNIVERSITY.

#include<iostream.h>
#include<conio.h>

void msu()
{
cout<<"\n The name of my university is `The Maharaja Sayajirao University'at
Baroda.";
cout<<"\n It was intialy known as `Baroda College'.";
cout<<"\n The MSU is public University.";
cout<<"\n It was Orginally established as a college in 1881.";
cout<<"\n MSU have 14 faculties.";
cout<<"\n It has a huge library called `The Hansa Mehta Library'.";
cout<<"\n The university offers Undergraduate,Postgraduate and Doctral programs
etc.";
}

void main()
{
clrscr();
msu ();
[Link]();
[Link]();
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 29-01-2021
//SET : 1(P-2)
//AIM : TO DISPLAY YOUR BIODATA.
// (FUNCTION NAME MUST BE YOUR NAME)

#include<iostream.h>
#include<conio.h>

void prabhat()
{
cout<<"\n\n BIO-DATA";
cout<<"\n Name : Prabhat Dinesh Singh";
cout<<"\n Date Of Birth : 07/10/2000";
cout<<"\n Nationality : Indian";
cout<<"\n Height : 170cm";
cout<<"\n Education Qualification : [Link](Mathematics)";
cout<<"\n Languages Known : Gujarati,Hindi,English";
cout<<"\n Hobbies : Music,Gaming,Reading";
cout<<"\n Adress : B-102 Amrut Vatika Flat Indiranagari road,
Dashrath, Vadodara";
cout<<"\n Mobile No. : +919727077497";
cout<<"\n Email ID : ps17861@[Link]";
}

void main()
{
clrscr();
prabhat();
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 03-02-2021
//AIM : TO FIND ADDITION OF THREE NUMBERS USING FUNCTION.

#include<iostream.h>
#include<conio.h>

float addition(float x,float y,float z)


{
float ans1;
ans1 = x+y+z;
return ans1;
}

void main()
{
clrscr();
float a,b,c,ans;
cout<<"\nEnter any three numbers :";
cin>>a>>b>>c;
ans = addition(a,b,c);
cout<<"\nAddition of given three numbers is : "<<ans;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 03-02-2021
//AIM : TO FIND MAXIMUM OF TWO NUMBERS BY USING FUNCTION
// AND WITH MULTIPLE RETURN STATEMENTS.

#include<iostream.h>
#include<conio.h>

float maximum(float x,float y);

void main()
{
clrscr();
float a,b,ans;
cout<<"\nEnter any two numbers : ";
cin>>a>>b;
ans=maximum(a,b);
cout<<"\nMaximum of given two numbers is : "<<ans;
[Link]();
[Link]();
}

float maximum(float x,float y)


{
if(x>y)
{ return x;}
else
{ return y;}
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 03-02-2021
//AIM : TO FIND MINIMUM OF THREE NUMBERS
// WITHOUT MULTIPLE RETURN STATEMENTS.

#include<iostream.h>
#include<conio.h>

void minimum(float x,float y,float z);

void main()
{
clrscr();
float a,b,c,ans;
cout<<"\nEnter any three numbers : ";
cin>>a>>b>>c;
minimum(a,b,c);
[Link]();
[Link]();
}

void minimum(float x,float y,float z)


{
float min;
if(x<y)
{
if(x<z)
{
min=x;
}
else
{
min=z;
}
}
else
{
if(y<z)
{
min=y;
}
else
{
min=z;
}
}
cout<<"\nMinimum of given three numbers is : "<<min;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND FACTORIAL OF A NUMBER.

#include<iostream.h>
#include<conio.h>

int factorial(int n)
{
int fact=1;
for(int i=1;i<=n;i++)
{
fact=fact*i;
}
return fact;
}

void main()
{
clrscr();
int a,x;
cout<<"\nEnter the number for factorial :";
cin>>x;
a=factorial(x);
cout<<"\nFactorial of `"<<x<<"' is : "<<a;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND MAXIMUM OF THREE NUMBERS
// WITH RETURN AND TERNERY OPERATOR.

#include<iostream.h>
#include<conio.h>

float maximum(float x,float y,float z);

void main()
{
clrscr();
float a,b,c,M;
cout<<"\nEnter any three numbers : ";
cin>>a>>b>>c;
M=maximum(a,b,c);
cout<<"\nMaximum of "<<a<<", "<<b<<" and "<<c<<" is : "<<M;
[Link]();
[Link]();
}

float maximum(float x,float y,float z)


{
float m,n;
m=(x>y)?x:y;
n=(m>z)?m:z;
return n;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND FIFTH POWER OF A NUMBER
// BY USING THE FUNCTION DECLARATION.

#include<iostream.h>
#include<conio.h>

void fifthpower()
{
int x;
cout<<"\nEnter any integer : ";
cin>>x;
cout<<"\nFifth power of given numer is : "<<x*x*x*x*x;
}

void main()
{
clrscr();
fifthpower();
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND `C(n,r)' FOR GIVEN `n' AND `r'
// BY USING FUNCTION DECLARATION.

#include<iostream.h>
#include<conio.h>

int factorial(int a)
{
int fact,i;
fact=1;
for(i=1;i<=a;i++)
{
fact=fact*i;
}
return fact;
}

void main()
{
clrscr();
int n,r,nfact,rfact,dfact,ans;
cout<<"\nEnter value of `n'and `r' such that n>r : ";
cin>>n>>r;
nfact=factorial(n);
rfact=factorial(r);
dfact=factorial(n-r);
ans=nfact/(rfact*dfact);
cout<<"\nThe value of `"<<n<<"C"<<r<<"' is : "<<ans;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND AREA OF TRIANGLE WITH THE FORMULA
// sqrt(s*(s-a)*(s-b)*(s-c)).

#include<iostream.h>
#include<conio.h>
#include<math.h>

float area(float x,float y,float z);

void main()
{
clrscr();
float a,b,c,A;
cout<<"\nEnter the length of sides of a triangle : ";
cin>>a>>b>>c;
A=area(a,b,c);
cout<<"\nArea of triangle with given sides is : "<<A;
[Link]();
[Link]();
}

float area(float x,float y,float z)


{
float s;
s=(x+y+z)/2;
return sqrt(s*(s-x)*(s-y)*(s-z));
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND A.M.,G.M. AND H.M.
// FOR GIVEN TWO NUMBERS.

#include<iostream.h>
#include<conio.h>
#include<math.h>

float x,y;

void arithmetic()
{
cout<<"\nArithmetic Mean of given number is : "<<(x+y)/2;
}

void geometric()
{
cout<<"\nGeometric Mean of given number is : "<<sqrt(x*y);
}

void harmonic()
{
cout<<"\nHarmonic Mean of given number is : "<<(2*x*y)/(x+y);
}

void main()
{
clrscr();
cout<<"\nEnter any two numbers = ";
cin>>x>>y;
arithmetic();
geometric();
harmonic();
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-02-2021
//AIM : TO FIND AREA OF CIRCLE,SQUARE AND RECTANGLE.

#include<iostream.h>
#include<conio.h>

void circle(float a)
{
cout<<"\nArea of Circle = "<<(3.14*a*a);
}

void rectangle(float p,float q)


{
cout<<"\nArea of Rectangle = "<<(p*q);
}

void square(float z)
{
cout<<"\nArea of Square = "<<(z*z);
}

void main()
{
clrscr();
float r,l,b,x;
cout<<"\nEnter radius of circle : ";
cin>>r;
circle(r);
cout<<"\nEnter length and breadth of rectangle : ";
cin>>l>>b;
rectangle(l,b);
cout<<"\nEnter length of square : ";
cin>>x;
square(x);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 10-02-2021
//AIM : TO FIND AREA OF TRIANGLE FOR GIVEN
// HEIGHT AND BASE WITH FUNCTION DECLARATION.

#include<iostream.h>
#include<conio.h>

void area(float x,float y);

void main()
{
clrscr();
float b,h;
cout<<"\nEnter the base and height of a triangle respectively : ";
cin>>b>>h;
area(b,h);
[Link]();
[Link]();
}

void area(float x,float y)


{
float ans;
ans=(0.5)*x*y;
cout<<"\nArea of triangle with given base and height is : "<<ans;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 10-02-2021
//AIM : TO FIND AREA OF CYLINDER FOR THE GIVEN
// HEIGHT AND RADIUS WITH FUNCTION DECLARATION.

#include<iostream.h>
#include<conio.h>

float area(float x,float y);

void main()
{
clrscr();
float r,h,A;
cout<<"\nEnter the radius and height of cylinder respectively : ";
cin>>r>>h;
A=area(r,h);
cout<<"\nArea of cylinder with given radius and height is : "<<A;
[Link]();
[Link]();
}

float area(float x,float y)


{
float ans;
ans=2*3.14*x*(x+y);
return ans;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 10-02-2021
//AIM : TO FIND SUM OF FIRST `n'
// NATURAL NUMBERS WITHOUT RETURN.

#include<iostream.h>
#include<conio.h>

void sum(int n);

void main()
{
clrscr();
int n;
cout<<"\nEnter any natural number : ";
cin>>n;
sum(n);
[Link]();
[Link]();
}

void sum(int n)
{
int x=0,i;
for(i=1;i<=n;i++)
{
x=x+i;
}
cout<<"\nSum of first `"<<n<<"' natural number is : "<<x;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 10-02-2021
//AIM : TO FIND SUM OF SQUARE FIRST `n' NATURAL NUMBERS.

#include<iostream.h>
#include<conio.h>

int sum(int x);

void main()
{
clrscr();
int n,s;
cout<<"\nEnter any natural number : ";
cin>>n;
s=sum(n);
cout<<"\nSum of square of first `"<<n<<"' natural number is : "<<s;
[Link]();
[Link]();
}

int sum(int x)
{
int i,sum1=0;
for(i=1;i<=x;i++)
{
sum1=sum1+(i*i);
}
return sum1;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 10-02-2021
//AIM : TO FIND SUM OF CUBES OF FIRST `n' NATURAL NUMBERS.

#include<iostream.h>
#include<conio.h>

int sum(int x);

void main()
{
clrscr();
int n,s;
cout<<"\nEnter any natural number : ";
cin>>n;
s=sum(n);
cout<<"\nSum of cubes of first `"<<n<<"' natural number is : "<<s;
[Link]();
[Link]();
}

int sum(int x)
{
int i,sum1=0;
for(i=1;i<=x;i++)
{
sum1=sum1+(i*i*i);
}
return sum1;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11-02-2021
//AIM : TO FIND AREA AND CIRCUMFERENCE OF CIRCLE WITH GIVEN RADIUS.

#include<iostream.h>
#include<conio.h>

void circle(float r)
{
cout<<"\nEnter radius of Circle : ";
cin>>r;
cout<<"\nArea of Circle with "<<r<<"(radius) is : "<<(3.14*r*r); cout<<"\
nCircumference of Circle with "<<r<<"(radius) is : "<<(2*3.14*r);
}

void main()
{
clrscr();
float r;
circle(r);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11-02-2021
//AIM : TO FIND `nPr' FOR GIVEN `n' AND `r'.

#include<iostream.h>
#include<conio.h>

int factor(int n)
{
int fact=1;
for(int i=1;i<=n;i++)
fact=fact*i;
return fact;
}

void main()
{
int n,r,A,B;
cout<<"\nEnter value of `n' and `r' for `nPr' :";
cin>>n>>r;
A=factorial(n);
B=factorial(n-r);
if(n<r);
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11-02-2021
//AIM : TO FIND MULTIPLICATION FOR GIVEN `n'.

#include<iostream.h>
#include<conio.h>

void table(int n)
{
cout<<"\nEnter any positive number : ";
cin>>n;
for(int i=1;i<=10;i++)
cout<<"\n "<<n<<" * "<<i<<" = "<<n*i;
}

void main()
{
int n;
table(n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11-02-2021
//AIM : TO CONVERT GIVEN WEIGHT IN POUND
// INTO KILOGRAM.(1kg = 0.453lb)

#include<iostream.h>
#include<conio.h>

float weight(float p)
{
return 0.453*p;
}

void main()
{

clrscr();
float pound,kg;
cout<<"\nEnter weight in `Pound' : ";
cin>>pound;
kg=weight(pound); cout<<"\
n"<<pound<<"lb = "<<kg<<"kg";
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 17-02-2021
//AIM : TO FIND A.M.,G.M. AND H.M.
// USING ONE FUNCTION(WITHOUT GLOBAL VARIABLE).

#include<iostream.h>
#include<conio.h>
#include<math.h>

void mean(float x,float y)


{
cout<<"\nArithmetic Mean of given two numbers : "<<(x+y)/2;
cout<<"\nGeometric Mean of given two numbers : "<<(sqrt(x*y));
cout<<"\nHarmonic Mean of given two numbers : "<<(2*x*y/(x+y));
}

void main()
{
clrscr();
float a,b;
cout<<"\nEnter any two positive numbers : ";
cin>>a>>b;
mean(a,b);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 17-02-2021
//AIM : TO CONVERT DATE OF THE FORM DD/MM/YYYY TO
// MONTH,DATE AND YEAR(USE SWITCH).

#include<iostream.h>
#include<conio.h>

void date(int a,int b,int c)


{
cout<<"\nYour entered `Date' is : "<<a<<"/"<<b<<"/"<<c;
switch(b)
{
case 1 : cout<<"\nJanuary";
break; case 2 : cout<<"\nFebruary";
break; case 3 : cout<<"\nMarch";
break; case 4 : cout<<"\nApril";
break; case 5 : cout<<"\nMay";break;
case 6 : cout<<"\nJune"; break;
case 7 : cout<<"\nJuly"; break;
case 8 : cout<<"\nAugust";
break; case 9 : cout<<"\nSeptember";
break; case 10 : cout<<"\nOctober";
break; case 11 : cout<<"\nNovember";
break; case 12 : cout<<"\nDecember";
break; default :
cout<<"\nYou entered wrong number.";
}
cout<<" "<<" "<<a<<","<<c;
}

void main()
{
clrscr();
int d,m,y;
cout<<"\nEnter any `Date' : ";
cin>>d;
cout<<"\nEnter any `Month': ";
cin>>m;
cout<<"\nEnter any `Year' : ";
cin>>y;
date(d,m,y);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 17-02-2021
//AIM : TO CHECK THE YEAR IS LEAP YEAR OR NOT.

#include<iostream.h>
#include<conio.h>

int y;

void year()
{
if((y%4==0 && y%100!=0)||(y%400==0))
{
cout<<"\nThe given year is leap year.";
}
else
{
cout<<"\nThe given year is not leap year.";
}
}

void main()
{
clrscr();
cout<<"\nEnter any year : ";
cin>>y;
year();
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 18-02-2021
//AIM : TO DETERMINE WHETHER THE ROOTS OF QUADRATIC EQUATION ARE
// REAL AND DISTINCT<REAL AND EQUAL OR IMAGINARY.(COMPLEX
// ROOTS)[ax^2+bx+c=0]

#include<iostream.h>
#include<conio.h>

void roots(float a,float b,float c)


{
float d;
d=(b*b)-(4*a*c);
if(d>0)
cout<<"\nThe roots of given equation are real and distinct.";
if(d==0)
cout<<"\nThe roots of given equation are real and equal.";
if(d<0)
cout<<"\nThe roots of given equation are imaginary.";
}

void main()
{
clrscr();
float a,b,c;
cout<<"\nEnter coefficients a,b and c of equation `ax^2+bx+c=0' : ";
cin>>a>>b>>c;
roots(a,b,c);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 18-02-2021
//AIM : TO FIND GCD OF TWO NUMBERS.

#include<iostream.h>
#include<conio.h>

void gcd(int a,int b)


{
int r;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
cout<<"\nGCD of given two numbers is : "<<a;
}

void main()
{
clrscr();
int a,b;
cout<<"\nEnter any two positive integers : ";
cin>>a>>b;
gcd(a,b);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 18-02-2021
//AIM : TO FIND LCM OF TWO NUMBERS.

#include<iostream.h>
#include<conio.h>

void lcm(int a,int b)


{
int r,s,t;
s=a;
t=b;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
cout<<"\nLCM of given two numbers is : "<<(s*t)/a;
}

void main()
{
clrscr();
int a,b;
cout<<"\nEnter any two numbers : ";
cin>>a>>b;
lcm(a,b);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 18-02-2021
//AIM : TO PRINT FIRST HUNDRED NATURAL NUMBERS,TEN IN EACH ROW.
// 1 2 3....10
// 11 12 13....20
// 21 22 23.......30
// ... ... ...

#include<iostream.h>
#include<conio.h>

void hundred(int i);

void main()
{
int i;
hundred
(i);
[Link]();
[Link]();
}

void hundred(int i)
{
for(i=1;i<=100;i++)
cout<<i<<"\t";
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 24-02-2021
//AIM : TO CHECK GIVEN NUMBERS IS EVEN OR ODD.

#include<iostream.h>
#include<conio.h>

void number(int n)
{
cout<<"\nEnter any integer : ";
cin>>n;
if(n%2==0)
cout<<"\nGiven number is even.";
else
cout<<"\nGiven number is odd.";
}

void main()
{
clrscr();
int n;
number(n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 25-02-2021
//AIM : TO CHECK WHETHER THE GIVEN NUMBER IS PRIME OR NOT.

#include<iostream.h>
#include<conio.h>
#include<math.h>

void prime(int n)
{
int c=0;
cout<<"\nEnter any integer : ";
cin>>n;
if(n==1)
cout<<"\nGiven number is not a prime.";
if(n==2)
cout<<"\nGiven number is prime.";
if(n>2)
{
for(int i=2;i<n;i++)
{
if(n%i==0)
c++;
}
if(c==0)
cout<<"\nGiven number is prime.";
else
cout<<"\nGiven number is not a prime.";
}
}

void main()
{
clrscr();
int n;
prime(n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 24-02-2021
//AIM : TO FIND SUM OF DIGITS OF GIVEN NUMBER.

#include<iostream.h>
#include<conio.h>

void sum(long int n)


{
long int r,t=0;
cout<<"\nEnter any number : ";
cin>>n;
while(n!=0)
{
r=n%10;
t=t+r;
n=n/10;
}
cout<<"\nSum of digits of given number : "<<t;
}

void main()
{
clrscr();
long int n;
sum(n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 2018033800098741
// : 25-02-2021
PRN : 3(P-8)
// : TO FIND A ROOT OF `f(x)=3x+sin(x)-
// USING `NEWTON RAPHSON METHOD'.

#include<iostream.h>
#include<conio.h>
#include<math.h>

float f(float x)
{
return (3*x+sin(x)-exp(x));
}

float df(float x)
{
return (3+cos(x)-exp(x));
}

void main()
{
clrscr();int i=1;
float a,b,x,ans,d,e=0.0001;
do
{
cout<<"\nEnter value of `a' and `b' such that `f(a)*f(b)<0' : ";
cin>>a>>b;
}while(f(a)*f(b)>0);

x=(a+b)/2;

cout<<"\nIteration \t x \t f(x) ";


cout<<"\n ";

do
{
cout<<"\n "<<i<<" \t "<<x<<" \t "<<f(x);
if(f(a)*f(x)<0)
ans=x-(f(x)/df(x));
d=fabs(x-ans);
i++;
x=ans;
}while(d>e);
cout<<"\nApproximate root for given equation is : "<<x;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 2018033800098741
// : 25-02-2021
PRN : 3(P-9)
// : TO FIND A ROOT OF `f(x)=3x+sin(x)-
// USING `BISECTION METHOD'.

#include<iostream.h>
#include<conio.h>
#include<math.h>

double f(double x)
{
double ans;
ans=3*x+sin(x)-exp(x);
return ans;
}

void main()
{
clrscr();
float a,b,x,d,e=0.0001;
int i=1;
do
{
cout<<"\nEnter value of `a' and `b' such that `f(a)*f(b)<0' : ";
cin>>a>>b;
}while(f(a)*f(b)>0);

cout<<"\nIteration \t x \t f(x) ";


cout<<"\n ";

do
{
x=(a+b)/2;
cout<<"\n "<<i<<" \t "<<x<<" \t "<<f(x);
if(f(a)*f(x)<0)
b=x;
if(f(x)*f(b)<0)
a=x;
d=fabs(a-b);
i++;
}while(d>e);
cout<<"\nApproximate root for given equation is : "<<x;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 25-02-2021
//AIM : TO FIND A ROOT OF `f(x)=sin(x)-exp(x)+2'
// USING `BISECTION METHOD'.

#include<iostream.h>
#include<conio.h>
#include<math.h>

double f(double x)
{
double ans;
ans=sin(x)-exp(x)+2;
return ans;
}

void main()
{
clrscr();
float a,b,x,d,e=0.0001;
int i=1;
do
{
cout<<"\nEnter value of `a' and `b' such that `f(a)*f(b)<0' : ";
cin>>a>>b;
}while(f(a)*f(b)>0);

cout<<"\nIteration \t x \t f(x) ";


cout<<"\n ";

do
{
x=(a+b)/2;
cout<<"\n "<<i<<" \t "<<x<<" \t "<<f(x);
if(f(a)*f(x)<0)
b=x;
if(f(x)*f(b)<0)
a=x;
d=fabs(a-b);
i++;
}while(d>e);
cout<<"\nApproximate root for given equation is : "<<x;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 25-02-2021
//AIM : TO FIND A ROOT OF `f(x)=x*exp(x)-3'
// USING `NEWTON RAPHSON METHOD'.

#include<iostream.h>
#include<conio.h>
#include<math.h>

float f(float x)
{
return (x*exp(x)-3);
}

float df(float x)
{
return (x*exp(x)+exp(x));
}

void main()
{
clrscr();int i=1;
float a,b,x,ans,d,e=0.0001;
do
{
cout<<"\nEnter value of `a' and `b' such that `f(a)*f(b)<0' : ";
cin>>a>>b;
}while(f(a)*f(b)>0);

x=(a+b)/2;

cout<<"\nIteration \t x \t f(x) ";


cout<<"\n ";

do
{
cout<<"\n "<<i<<" \t "<<x<<" \t "<<f(x);
if(f(a)*f(x)<0)
ans=x-(f(x)/df(x));
d=fabs(x-ans);
i++;
x=ans;
}while(d>e);
cout<<"\nApproximate root for given equation is : "<<x;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 03-03-2021
//AIM : TO FIND ADDITION AND AVERAGE OF THREE NUMBERS
// BY USING DEFAULT ARGUMENT.

#include<iostream.h>
#include<conio.h>

void addition(int a=10,int b=20,int c=30);

void average(int a=10,int b=20,int c=30);

void main()
{
clrscr();
addition();
average();
[Link]();
[Link]();
}

void addition(int x,int y,int z)


{
int c;
c=x+y+z;
cout<<"\nAddition of given three numbers is : "<<c;
}

void average(int x,int y,int z)


{
float d;
d=(x+y+z)/3;
cout<<"\nAverage of given three numbers is : "<<d;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-03-2021
//AIM : TO FIND ADDITION AND AVERAGE OF FOUR NUMBERS
// BY TAKING TWO OF THEM AS DEFAULT ARGUMENT.

#include<iostream.h>
#include<conio.h>

void addition(int a,int b,int c=20,int d=25)


{
float ans;
ans=a+b+c+d;
cout<<"\nAddition of given four numbers "<<a<<","<<b<<","<<c<<" and "<<d<<" :
"<<ans;
}

void average(float a,float b,float c=20,float d=25)


{
float ans;
ans=(a+b+c+d)/4;
cout<<"\nAverage of given four numbers "<<a<<","<<b<<","<<c<<" and "<<d<<" :
"<<ans;
}

void main()
{
clrscr();
float x,y;
cout<<"\nEnter any two numbers : ";
cin>>x>>y;
addition(x,y);
average(x,y);
[Link]();
[Link]();
}

void addition(int x,int y,int z)


{
int c;
c=x+y+z;
cout<<"\nAddition of given three numbers is : "<<c;
}

void average(int x,int y,int z)


{
float d;
d=(x+y+z)/3;
cout<<"\nAverage of given three numbers is : "<<d;
}
//NAME : Prabhat Singh
//PRN :
//DATE : 01-03-2021
//SET : 4(P-2)
//AIM : TO FIND MAXIMUM OF GIVEN `n' NUMBERS.

#include<iostream.h>
#include<conio.h>

int max(int a,int b)


{
return ((a>b)?a:b);
}

void main()
{
clrscr();
int n,i,a[20],ans;
cout<<"\nEnter how many value you want to enter ? : ";
cin>>n;
cout<<"\nEnter those numbers `"<<n<<"' numbers : ";

for(i=0;i<n;i++)
{ cin>>a[i]; }

ans=a[0];

for(i=1;i<n;i++)
{ ans=max(ans,a[i]); }

cout<<"\nMaximum of given `"<<n<<"' numbers = "<<ans;


[Link]();
[Link]();
}
//NAME : Prabhat Singh
//PRN :
//DATE : 01-03-2021
//SET : 4(P-3)
//AIM : TO FIND MINIMUM OF GIVEN `n' NUMBERS.

#include<iostream.h>
#include<conio.h>

int mini(int a,int b)


{
return ((a<b)?a:b);
}

void main()
{
clrscr();
int n,i,a[20],ans;
cout<<"\nEnter how many value you want to enter ? : ";
cin>>n;
cout<<"\nEnter those numbers `"<<n<<"' numbers : ";

for(i=0;i<n;i++)
{ cin>>a[i]; }

ans=a[0];

for(i=1;i<n;i++)
{ ans=mini(ans,a[i]); }

cout<<"\nMinimum of given `"<<n<<"' numbers = "<<ans;


[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 01/03/2021
//AIM : TO FIND GCD GIVEN `n' NUMBERS.

#include<iostream.h>
#include<conio.h>

int gcd(int a,int b);

void main()
{
clrscr();
int i,n,a[10];
cout<<"\nEnter hoe many numbers you want to enter ? : \n";
cin>>n;
cout<<"\nEnter those `"<<n<<"' numbers : \n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<=n-1;i++)
{
a[i+1]=gcd(a[i],a[i+1]);
}
cout<<"\nGCD of given `"<<n<<"' numbers is : "<<a[i];
[Link]();
[Link]();
}

int gcd(int a,int b)


{
int min,max,gcd;
min=(a<b)?a:b;
max=(a>b)?a:b;

while(min>0)

{
gcd=min;
min=max%min;
max=gcd;
}
return gcd;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 01/03/2021
//AIM : TO FIND LCM GIVEN `n' NUMBERS.

#include<iostream.h>
#include<conio.h>

int lcm(int a,int b);

void main()
{
clrscr();
int i,n,a[10];
cout<<"\nEnter how many numbers you want to enter ? : \n";
cin>>n;
cout<<"\nEnter those `"<<n<<"' numbers : \n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n-1;i++)
{
a[i+1]=lcm(a[i],a[i+1]);
}
cout<<"\nLCM of given `"<<n<<"' numbers is : "<<a[i];
[Link]();
[Link]();
}

int lcm(int a,int b)


{
int min,max,lcm,gcd; min=(a<b)?
a:b;
max=(a>b)?a:b;

while(min>0)

{
gcd=min;
min=max%min;
max=gcd;
}
lcm=(a*b)/gcd;
return lcm;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 08-03-2021
//AIM : TO FIND AVERAGE OF `n' NUMBERS.

#include<iostream.h>
#include<conio.h>

void average(float b[15],int z);

void main()
{
clrscr();
int n;float a[15];
cout<<"\nEnter how many value you want to enter ? : ";
cin>>n;
cout<<"\nEnter those `"<<n<<"' numbers : ";
for(int i=0;i<n;i++)
{ cin>>a[i]; }
average(a,n);
[Link]();
[Link]();
}

void average(float b[15],int z)


{
int i;
float sum=0,avg;
for(i=0;i<z;i++)
{
sum=sum+b[i];
}
avg=sum/z;
cout<<"\nAverage of given numbers is = "<<avg;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 04-03-2021
//AIM : TAKE AN ARRAY OF `n' NUMBERS AND PRINT THEIR SQUARE.

#include<iostream.h>
#include<conio.h>

float square(float a)
{
return a*a;
}

void main()
{
clrscr();
float a[25];
int n;
cout<<"\nHow many numbers do you want to enter ? : ";
cin>>n;
cout<<"\nEnter those numbers : ";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nTheir squares are : ";
for(i=0;i<n;i++)
{
cout<<"\nSquares ("<<a[i]<<") : "<<square(a[i]);
}
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 2018033800098741
// : 22-03-2021
PRN : 4(P-8)
// : TO TAKE AN ARRAY OF `n' NUMBERS IN
// SENT EACH ARRAY ELEMENT TO THE MULTIPLY
// THEM WITH 5 AND PRINT.

#include<iostream.h>
#include<conio.h>

float multi(float c)
{
return 5*c;
}

void main()
{
clrscr();
float a[25];
int n;
cout<<"\nHow many numbers do you want to enter ? : ";
cin>>n;
cout<<"\nEnter those numbers : ";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nThe elements are : ";
for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
cout<<"\nAfter multiplying each numbers by `5' the numbers are : ";
for(i=0;i<n;i++)
{
cout<<"\n"<<multi(a[i])<<"("<<a[i]<<"*5)";
cout<<"\n";
}
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 2018033800098741
// : 22-03-2021
PRN : 4(P-9)
// : TO TAKE AN ARRAY OF `n' NUMBERS IN
// SENT THAT ENTIRE ARRAY ELEMENT TO THE FUNCTION
// ADD 10 EACH ELEMENT AND PRINT.

#include<iostream.h>
#include<conio.h>

void add(float a[25],int n)


{
cout<<"\nAfter adding 10 to each element of array,"
<<"element of resulting array are : ";
for(int i=0;i<n;i++)
{
a[i]=a[i]+10;
cout<<a[i]<<" ";
}
}

void main()
{
clrscr();
float b[25];
int n;
cout<<"\nHow many numbers do you want to enter ? : ";
cin>>n;
cout<<"\nEnter those numbers : ";
for(int i=0;i<n;i++)
cin>>b[i];
cout<<"\nThe elements are : ";
for(i=0;i<n;i++)
cout<<b[i]<<" ";
add(b,n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 22-03-2021
//AIM : TO COUNT THE NUMBER OF TIME THE GIVEN NUMBER
// `x' APPEARS AMONG THE GIVEN ARRAY OF NUMBERS.

#include<iostream.h>
#include<conio.h>

void repeat(float a[20],int n)


{
float x;
int t=0;
cout<<"\nEnter any number from the above array : ";
cin>>x;
for(int i=0;i<n;i++)
{
if(x==a[i])
t++;
}
cout<<"\nThe number "<<x<<" is appearing in array "<<t<<" times.";
}

void main()
{
clrscr();
float c[20];
int n;
cout<<"\nHow many numbers do you want to enter : ";
cin>>n;
repeat(c[20],n);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 01-03-2021
//AIM : TO CREATE A STRUCTURE WITH NAME `date',
// TAKE INPUT IN `main()' & PRINT IT
// BY USING FUNCTION.

#include<iostream.h>
#include<conio.h>

struct date
{
int day,month,year;
};

void print(date y);

void main()
{
clrscr();
date x;
cout<<"\nEnter date in the form of day,month,year : ";
cin>>[Link]>>[Link]>>[Link];
print(x);
[Link]();
[Link]();
}

void print(date y)
{
cout<<"\nDate entered by you is : \n";
cout<<[Link]<<"-"<<[Link]<<"-"<<[Link];
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 22-03-2021
//AIM : TO CHECK A VECTOR OF ORDER `3' AND
// PRINT IT AS ROW VECTOR.

#include<iostream.h>
#include<conio.h>

void print(float a[3])


{
cout<<"\nGiven vector is : ("<<a[0]<<","<<a[1]<<","<<a[2]<<")";
}

void main()
{
clrscr();
float d[3];
cout<<"\nEnter elements of vector of order `3' : ";
for(int i=0;i<3;i++)
cin>>d[i];
print(d);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 23-03-2021
//AIM : TO TAKE A VECTOR OF ORDER `4' AND
// PRINT IT AS COLUMN VECTOR.

#include<iostream.h>
#include<conio.h>

void print(float v[4])


{
int i;
cout<<"\nYou entered vector as column vector is : \n";
for(i=0;i<4;i++)
{
cout<<v[i]<<"\n";
}
}

void main()
{
clrscr();
float v1[4];
cout<<"\nEnter elements of vector of order `4' : ";
for(int i=0;i<4;i++)
{
cin>>v1[i];
}
print(v1);
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 23-03-2021
//AIM : TO FIND MODULUS OF GIVEN VECTOR USING FUNCTIONS.

#include<iostream.h>
#include<conio.h>
#include<math.h>

struct vector
{
int n,a[10];
};

vector input();
void print(vector v);
float modulus(vector v);

void main()
{
clrscr();
float m;
vector v1;
v1=input() ;
print(v1);
m=modulus(v1);
cout<<"\nModus of given vector is : \n"<<m;
[Link]();
[Link]();
}

vector input()
{
int i;vector v;
cout<<"\nEnter the dimension of vector :\n";
cin>>v.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<v.n;i++)
{
cin>>v.a[i];
}
return v;
}

void print(vector v)
{
int i;
cout<<"\nYour entered vector is :\n ";
cout<<"(";
for(i=0;i<v.n;i++)
{
cout<<v.a[i];
if(i<(v.n-1))
cout<<",
}
cout<<")
}
float modulus(vector v)
{
int i;float sum=0;
for(i=0;i<v.n;i++)
{
sum=sum+(v.a[i])*v.a[i];
}
return (sqrt(sum));
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
//SET : 5(P-3)
//AIM : TO TAKE A VECTOR AND PRINT ITS CUBE.

#include<iostream.h>
#include<conio.h>

struct vector
{
int n;float a[10];
};

vector input();
void print(vector v);

void main()
{
clrscr();
vector P;
P=input();
print(P);
[Link]();
[Link]();
}

vector input()
{
int i;vector v;
cout<<"\nEnter the dimension of vector :\n";
cin>>v.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<v.n;i++)
{
cin>>v.a[i];
}
return v;
}

void print(vector v)
{
int i;
cout<<"( ";
for(i=0;i<v.n;i++)
{
cout<<v.a[i]*v.a[i]*v.a[i]<<" ";
}
cout<<")";
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
//SET : 5(P-4)
//AIM : TO FIND SUM OF TWO VECTORS IN `R^n'.

#include<iostream.h>
#include<conio.h>

struct vector
{
int n,a[10];
};

vector input();
void print(vector v);
vector sum(vector v1, vector v2);

void main()
{
clrscr();
float m;
vector v1,v2,v3;
v1=input();
v2=input();
cout<<"\nFirst vector you have entered vector is :\n";
print(v1);
cout<<"\nSecond vector you have entered vector is :\n";
print(v2);
v3=sum(v1,v2);
if(v1.n!=v2.n)
cout<<"\nSum of given two vector is not possible as "
<<"their dimension are not same.";
else
{
cout<<"\nSum of given two vector is :\n";
print(v3);
}
[Link]();
[Link]();
}

vector input()
{
int i;vector v;
cout<<"\nEnter the dimension of vector :\n";
cin>>v.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<v.n;i++)
{
cin>>v.a[i];
}
return v;
}
void print(vector v)
{
int i;
cout<<"(";
for(i=0;i<v.n;i++)
{
cout<<v.a[i];
if(i<(v.n-1))
cout<<",";
}
cout<<")";
}

vector sum(vector v1,vector v2)


{
int i;vector v;
v.n=v1.n;
for(i=0;i<v.n;i++)
{
v.a[i]=v1.a[i]+v2.a[i];
}
return (v);
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 10-03-2021
//SET : 5(P-5)
//AIM : TO FIND INNER PRODUCT OF TWO VECTORS IN `R^n'.

#include<iostream.h>
#include<conio.h>

struct vector
{
int n;
float a[10];
};

vector input();
void print(vector v);
float inner_product(vector x,vector y);

void main()
{
clrscr();
float ans;
vector P,Q;
P=input();
Q=input();
cout<<"\nFirst vector you have entered vector is :\n";
print(P);
cout<<"\nSecond vector you have entered vector is :\n";
print(Q);
if(P.n!=Q.n)
cout<<"\nInner product of given two vector is not possible as "
<<"their dimension are not same.";
else
{
ans=inner_product(P,Q);
cout<<"\nInner product of given two vector is :\n"<<ans;
}
[Link]();
[Link]();
}

vector input()
{
int i;vector v;
cout<<"\nEnter the dimension of vector :\n";
cin>>v.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<v.n;i++)
{
cin>>v.a[i];
}
return v;
}
void print(vector v)
{
int i;
cout<<"(";
for(i=0;i<v.n;i++)
{
cout<<v.a[i];
if(i<(v.n-1))
cout<<",";
}
cout<<")";
}

float inner_product(vector x,vector y)


{
float s=0;int i;
for(i=0;i<x.n;i++)
{
s=s+x.a[i]*y.a[i];
}
return s;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23-03-2021
//SET : 5(P-6)
//AIM : TO FIND ANGLE BETWEEN TWO VECTORS IN `R^n'.

#include<iostream.h>
#include<conio.h>
#include<math.h>

struct vector
{
int n,a[10];
};

vector input();
void print(vector b);
float product(vector x,vector y);
float modulus(vector x);

void main()
{
clrscr();
float p,q,n,m,z;
vector x,y;
x=input();
y=input();
cout<<"\nFirst vector is :\n";
print(x);
cout<<"\nSecond vector is :\n";
print(y);
p=product(x,y);
m=modulus(x);
n=modulus(y);
q=acos(p/(m*n));
if(x.n!=y.n)
cout<<"\nAngle of given two vector is not possible as"
<<" their dimension are not same.";
else
{
cout<<"\nAngle of given two vector is :\n"<<(180/3.14)*q;
}
[Link]();
[Link]();
}

vector input()
{
int i;vector v;
cout<<"\nEnter the dimension of vector :\n";
cin>>v.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<v.n;i++)
{
cin>>v.a[i];
}
return v;
}

void print(vector v)
{
int i;
cout<<"(";
for(i=0;i<v.n;i++)
{
cout<<v.a[i];
if(i<(v.n-1))
cout<<",";
}
cout<<")";
}

float product(vector x,vector y)


{
int i;float z=0;
x.n=y.n;
for(i=0;i<x.n;i++)
{
z=z+(x.a[i]*y.a[i]);
}
return (z);
}

float modulus(vector x)
{
float y=0,z;
int i;
for(i=0;i<x.n;i++)
{
y=y+(x.a[i]*x.a[i]);
}
z=sqrt(y);
return z;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23-03-2021
//SET : 5(P-7)
//AIM : TO FIND POINTWISE MULTIPLICATION OF TWO VECTORS IN `R^n'.

#include<iostream.h>
#include<conio.h>

struct vector
{
int n,a[10];
};

vector input();
void print(vector b);
vector product(vector x,vector y);

void main()
{
clrscr();
vector x,y,z;
x=input();
y=input();
cout<<"\nFirst vector you have entered is :\n";
print(x);
cout<<"\nSecond vector you have entered is :\n";
print(y);
if(x.n!=y.n)
cout<<"\nMultiplication of given two vector is not possible as"
<<" their dimension are not same.";
else
{
z=product(x,y);
cout<<"\nPointwise multiplication of given two vector is :\n";
print(z);
}
[Link]();
[Link]();
}

vector input()
{
int i;vector c;
cout<<"\nEnter the dimension of vector :\n";
cin>>c.n;
cout<<"\nEnter the elements of vector of given order : \n";
for(i=0;i<c.n;i++)
{
cin>>c.a[i];
}
return c;
}
void print(vector b)
{
int i;
cout<<"(";
for(i=0;i<b.n;i++)
{
cout<<b.a[i];
if(i<(b.n-1))
cout<<",";
}
cout<<")";
}

vector product(vector x,vector y)


{
int i;vector z;
z.n=y.n;
for(i=0;i<z.n;i++)
{
z.a[i]=(x.a[i]*y.a[i]);
}
return (z);
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23/03/2021
//SET : 5(P-8)
//AIM : TO READ AND PRINT THE MATRIX USING
// STRUCTURE AND FUNCTION.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);

void main()
{
clrscr();
matrix m;
m=input();
cout<<"\nmatrix you have entered is :\n";
print(m);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23/03/2021
//SET : 5(P-9)
//AIM : TO TAKE A MATRIX `A' AND PRINT A MATRIX `3A'.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix multi(matrix w);

void main()
{
clrscr();
matrix x,z;
x=input();
z=multi(x);
cout<<"\nMatrix you have entered is :\n";
print(x);
cout<<"\n3A = \n";
print(z);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix multi(matrix w)
{
int i,j;
for(i=0;i<w.r;i++)
{
for(j=0;j<w.c;j++)
{
w.a[i][j]=3*w.a[i][j];
}
}
return (w);
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23/03/2021
//SET : 5(P-10)
//AIM : TO FIND SUM OF GIVEN TWO MATRICES.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix sum(matrix m1,matrix m2);

void main()
{
clrscr();
matrix m1,m2,m;
m1=input();
m2=input();
cout<<"\nFirst matrix `A' you have entered is :\n";
print(m1);
cout<<"\nSecond matrix `B' you have entered is :\n";
print(m2);
m=sum(m1,m2); if((m1.r!
=m2.r)||(m1.c!=m2.c))
{
cout<<"\nSum of given two matrices are not possible.";
}
else
{
cout<<"\nSum of given matrices `A+B' is : \n";
print(m);
}
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix sum(matrix m1,matrix m2)


{
int i,j;
matrix m;
m.r=m1.r;
m.c=m1.c;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
m.a[i][j]=m1.a[i][j]+m2.a[i][j];
}
}
return (m);
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23/03/2021
//SET : 5(P-11)
//AIM : TO CHECK WHETHER GIVEN MATRIX IS SYMMETRIC OR NOT.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
void symm(matrix y);

void main()
{
clrscr();
matrix x;
x=input();
cout<<"\nMatrix you have entered is :\n";
print(x);
if(x.r!=x.c)
{
cout<<"\nGiven matrix is not symmetric as it is not square matrix.";
}
else
symm(x);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

void symm(matrix y)
{
int i,j,count=0;
for(i=0;i<y.r;i++)
{
for(j=0;j<y.c;j++)
{
if(y.a[i][j]!=y.a[j][i])
{
count++;
}
}
}
cout<<"\nGiven matrix is symmatric.";
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 23/03/2021
//SET : 5(P-12)
//AIM : TO FIND TRANSPOSE GIVEN MATRIX.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix trans(matrix y);

void main()
{
clrscr();
matrix x,j;
x=input();
cout<<"\nMatrix you have entered is :\n";
print(x);

cout<<"\nTranspose of given matrix is :\n";


j=trans(x);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:\n";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix trans(matrix y)
{
int i,j;
for(i=0;i<y.c;i++)
{
for(j=0;j<y.r;j++)
{
cout<<y.a[j][i]<<"\t";
}
cout<<"\n";
}
return y;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 24/03/2021
//SET : 6(P-1)
//AIM : TO CHECK WHETHER THE TWO MATRICES ARE EQUAL OR NOT.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
void equality(matrix m1,matrix m2);

void main()
{
clrscr();
matrix m1,m2;
m1=input();
m2=input();
cout<<"\nFirst matrix you have entered is :\n";
print(m1);
cout<<"\nSecond matrix you have entered is :\n";
print(m2);
if((m1.r!=m2.r)||(m1.c!=m2.c))
{
cout<<"\nGiven two matrices are not equal.";
}
else
{
equality(m1,m2);
}
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

void equality(matrix m1,matrix m2)


{
int i,j,x=0;
for(i=0;i<m1.r;i++)
{
for(j=0;j<m1.c;j++)
{
if(m1.a[i][j]!=m2.a[i][j])
{
x++;
}
}
}
if(x==0)
{
cout<<"\nGiven two matrices are equal.";
}
else
{
cout<<"\nGiven two matrices are not equal.";
}
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 24/03/2021
//SET : 6(P-2)
//AIM : TO FIND SUBTRACTION OF GIVEN MATRIX.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix subtraction(matrix m1,matrix m2);

void main()
{
clrscr();
matrix m1,m2,m3;
m1=input();
m2=input();
cout<<"\nFirst matrix you have entered is :\n";
print(m1);
cout<<"\nSecond matrix you have entered is :\n";
print(m2);
m3=subtraction(m1,m2);
if((m1.r==m2.r)&&(m1.c==m2.c))
{
cout<<"\nSubraction of given matrix :\n";
print(m3);
}
else
{
cout<<"\nSubraction is not possible.";
}
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix subtraction(matrix m1,matrix m2)


{
matrix m;
int i,j;
m.r=m1.r;m.c=m1.c;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
m.a[i][j]=m1.a[i][j]-m2.a[i][j];
}
}
return m;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 24/03/2021
//SET : 6(P-3)
//AIM : TO FIND TRACE OF GIVEN MATRIX.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
int trace(matrix m);

void main()
{
clrscr();
int tr;
matrix m;
m=input();
cout<<"\nMatrix you have entered is :\n";
print(m);
if(m.r!=m.c)
{
cout<<"\nTrace of given matrix is npt possible as it is not a square matrix.";
}
else
{
tr=trace (m);
cout<<"\nTrace of given matrix is :"<<tr;
}
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

int trace(matrix m)
{
int i,j,ans=0;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
if(i==j)
ans=ans+m.a[i][j];
}
}
return ans;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 24/03/2021
//SET : 6(P-4)
//AIM : TO FIND SUM OF ALL ELEMENTS OF GIVEN MATRIX USING FUNCTION.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
int sum(matrix m);

void main()
{
clrscr();
matrix m;
int s;
m=input();
cout<<"\nMatrix you have entered is :\n";
print(m);
s=sum(m);
cout<<"\nSum of all elements of given matrix is :"<<s;
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

int sum(matrix m)
{
int i,j,ans=0;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
ans=ans+m.a[i][j];
}
}
return ans;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 24/03/2021
//SET : 6(P-5)
//AIM : TO FIND POINTWISE MULTIPLICATION OF GIVEN MATRICES USING FUNCTION.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix multiplication(matrix m1,matrix m2);

void main()
{
clrscr();
matrix m1,m2,m3;
m1=input();
m2=input();
cout<<"\nFirst matrix you have entered is :\n";
print(m1);
cout<<"\nSecond matrix you have entered is :\n";
print(m2);
m3=multiplication(m1,m2);
if((m1.r==m2.r)&&(m1.c==m2.c))
{
cout<<"\nMultipication of given matrices :\n";
print(m3);
}
else
{
cout<<"\nMultiplication is not possible.";
}
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix multiplication(matrix m1,matrix m2)


{
matrix m;
int i,j;
m.r=m1.r;
m.c=m1.c;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
m.a[i][j]=m1.a[i][j]*m2.a[i][j];
}
}
return m;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 25/03/2021
//SET : 6(P-6)
//AIM : TO INTERCHANGE TWO ROWS OF GIVEN MATRIX USING FUNCTION.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix interchange(matrix y,int r1,int r2);

void main()
{
clrscr();
int r1,r2;
matrix A,B;
A=input();
cout<<"\nMatrix you have entered is :\n";
print(A);
cout<<"\nEnter the rows you want to interchange :\n";
cin>>r1>>r2;
B=interchange(A,r1,r2);
cout<<"\nYour matrix after interchange is :\n";
print(B);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix interchange(matrix y,int r1,int r2)


{
int i,j; float K[10]; for(i=0;i<y.c;i+
+)
{
K[i]=y.a[r1-1][i];
y.a[r1-1][i]=y.a[r2-1][i];
y.a[r2-1][i]=K[i];
}
return y;
}
//NAME : Prabhat Singh
//PRN :
//DATE : 25-03-2021
//SET : 6(P-7)
//AIM : TO ARRANGE GIVEN n NUMBERS IN ASCENDING ORDER USING FUNCTION.

#include<iostream.h>
#include<conio.h>

void ascending(float a[10],int n);

void main()
{
clrscr();
float a[10];
int n;
cout<<"\nHow many numbers do you want ? :";
cin>>n;
cout<<"\nEnter those numbers :";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nNumbers you have entered is :";
for(i=0;i<n;i++)
cout<<" "<<a[i];
ascending(a,n);
[Link]();
[Link]();
}

void ascending(float a[10],int n)


{
float t;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
cout<<"\nGiven numbers in ascending order are :";
for(i=0;i<n;i++)
cout<<" "<<a[i];
}
//NAME : Prabhat Singh
//PRN :
//DATE : 25/03/2021
//SET : 6(P-8)
//AIM : TO INTERCHANGE TWO COLUMNS OF GIVEN MATRIX USING FUNCTION.

#include<iostream.h>
#include<conio.h>

struct matrix
{
int r,c;
float a[10][10];
};

matrix input();
void print(matrix m);
matrix interchange(matrix y,int c1,int c2);

void main()
{
clrscr();
int c1,c2;
matrix A,B;
A=input();
cout<<"\nMatrix you have entered is :\n";
print(A);
cout<<"\nEnter the columns you want to interchange :\n";
cin>>c1>>c2;
B=interchange(A,c1,c2);
cout<<"\nYour matrix after interchange is :\n";
print(B);
[Link]();
[Link]();
}

matrix input()
{
int i,j;matrix m;
cout<<"\nEnter the order of the matrix :\n";
cin>>m.r>>m.c;
cout<<"\nEnter the elements of matrix row-wise:";
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cin>>m.a[i][j];
}
}
return m;
}

void print(matrix m)
{
int i,j;
for(i=0;i<m.r;i++)
{
for(j=0;j<m.c;j++)
{
cout<<m.a[i][j]<<"\t";
}
cout<<"\n";
}
}

matrix interchange(matrix y,int c1,int c2)


{
int i,j; float K[10]; for(i=0;i<y.r;i+
+)
{
K[i]=y.a[i][c1-1];
y.a[i][c1-1]=y.a[i][c2-1];
y.a[i][c2-1]=K[i];
}
return y;
}
//NAME : Prabhat Singh
//PRN :
//DATE : 25-03-2021
//SET : 6(P-9)
//AIM : TO ARRANGE GIVEN n NUMBERS IN DESCENDING ORDER USING FUNCTION.

#include<iostream.h>
#include<conio.h>

void descending(float a[10],int n);

void main()
{
clrscr();
float a[10];
int n;
cout<<"\nHow many numbers do you want ? :";
cin>>n;
cout<<"\nEnter those numbers :";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nNumbers you have entered is :";
for(i=0;i<n;i++)
cout<<" "<<a[i];
descending(a,n);
[Link]();
[Link]();
}

void descending(float a[10],int n)


{
float t;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
cout<<"\nGiven numbers in descending order are :";
for(i=0;i<n;i++)
cout<<" "<<a[i];
}
//NAME : Prabhat Singh
//PRN :
//DATE : 25/03/2021
//SET : 6(P-10)
//AIM : TO FIND SUM OF TWO COMPLEX NUMBERS.

#include<iostream.h>
#include<conio.h>

struct complex
{
float i,r;
};

complex input();
void print(complex z);
complex sum(complex z,complex w);

void main()
{
clrscr();
complex z1,z2,z3;
z1=input();
z2=input();
cout<<"\nEnter first complex number you have entered is Z1 :";
print(z1);
cout<<"\nEnter second complex number you have entered is Z2 :";
print(z2);
z3=sum(z1,z2);
cout<<"\nZ1 + Z2 =";
print(z3);
[Link]();
[Link]();
}

complex input()
{
complex z;
cout<<"\nEnter Real and Imeginary part of complex number :";
cin>>z.r>>z.i;
return z;
}

void print(complex z)
{
cout<<"("<<z.r<<") + i("<<z.i<<")";
}

complex sum(complex z1,complex z2)


{
complex z;
z.r=z1.r+z2.r;
z.i=z1.i+z2.i;
return
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 25/03/2021
//SET : 6(P-11)
//AIM : TO FIND PRODUCT OF TWO COMPLEX NUMBERS.

#include<iostream.h>
#include<conio.h>

struct complex
{
float i,r;
};

complex input();
void print(complex z);
complex product(complex z,complex w);

void main()
{
clrscr();
complex z1,z2,z3;
z1=input();
z2=input();
cout<<"\nEnter first complex number you have entered is Z1 :";
print(z1);
cout<<"\nEnter second complex number you have entered is Z2 :";
print(z2);
z3=product(z1,z2);
cout<<"\nZ1 * Z2 =";
print(z3);
[Link]();
[Link]();
}

complex input()
{
complex z;
cout<<"\nEnter Real and Imeginary part of complex number :";
cin>>z.r>>z.i;
return z;
}

void print(complex z)
{
cout<<"("<<z.r<<") + i("<<z.i<<")";
}

complex product(complex z1,complex z2)


{
complex z;
z.r=((z1.r*z2.r)-(z1.i*z2.i));
z.i=((z1.r*z2.i)+(z1.i*z2.r));
return z;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 25/03/2021
//SET : 6(P-12)
//AIM : TO FIND DIVISION OF TWO COMPLEX NUMBERS.

#include<iostream.h>
#include<conio.h>

struct complex
{
float i,r;
};

complex input();
void print(complex z);
complex division(complex z,complex w);

void main()
{
clrscr();
complex z1,z2,z3;
z1=input();
z2=input();
cout<<"\nEnter first complex number you have entered is Z1 :";
print(z1);
cout<<"\nEnter second complex number you have entered is Z2 :";
print(z2);
z3=division(z1,z2);
cout<<"\nZ1 / Z2 =";
print(z3);
[Link]();
[Link]();
}

complex input()
{
complex z;
cout<<"\nEnter Real and Imeginary part of complex number :";
cin>>z.r>>z.i;
return z;
}

void print(complex z)
{
cout<<"("<<z.r<<") + i("<<z.i<<")";
}

complex division(complex z1,complex z2)


{
complex z; z.r=((z1.r*z2.r)+(z1.i*z2.i))/((z2.r*z2.r)+
(z2.i*z2.i));
z.i=((z1.i*z2.r)-(z1.r*z2.i))/((z2.r*z2.r)+(z2.i*z2.i));
return z;
}
//NAME : Prabhat Singh
//PRN : 2018033800098741
//DATE : 25/03/2021
//SET : 7(P-1)
//AIM : TO FIND SUBTRACTION OF TWO COMPLEX NUMBERS.

#include<iostream.h>
#include<conio.h>

struct complex
{
float i,r;
};

complex input();
void print(complex z);
complex subtraction(complex z,complex w);

void main()
{
clrscr();
complex z1,z2,z3;
z1=input();
z2=input();
cout<<"\nEnter first complex number you have entered is Z1 :";
print(z1);
cout<<"\nEnter second complex number you have entered is Z2 :";
print(z2);
z3=subtraction(z1,z2);
cout<<"\nZ1 - Z2 =";
print(z3);
[Link]();
[Link]();
}

complex input()
{
complex z;
cout<<"\nEnter Real and Imeginary part of complex number :";
cin>>z.r>>z.i;
return z;
}

void print(complex z)
{
cout<<"("<<z.r<<") + i("<<z.i<<")";
}

complex subtraction(complex z1,complex z2)


{
complex z;
z.r=z1.r-z2.r;
z.i=z1.i-z2.i;
return z;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
//SET : 7(P-2)
//AIM : TO FIND MAXIMUM OF THREE AND FOUR NUMBERS
// USING FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>

int maximum(int a,int b,int c);


int maximum(int a,int b,int c,int d);

void main()
{
clrscr();
int a,b,c,d,m1,m2;
cout<<"\nEnter any four integers : \n";
cin>>a>>b>>c>>d;
m1=maximum(a,b,c);
m2=maximum(a,b,c,d);
cout<<"\nMaximum of first three numbers is : "<<m1;
cout<<"\nMaximum of four numbers is : "<<m2;
[Link]();
[Link]();
}

int maximum(int a,int b,int c)


{
int max;
max=(a>b)?a:b;
max=(max>c)?max:c;
return max;
}

int maximum(int a,int b,int c,int d)


{
int max;
max=(a>b)?a:b;
max=(max>c)?max:c;
max=(max>d)?max:d;
return max;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
//SET : 7(P-3)
//AIM : TO FIND VOLUME OF CUBE,CYLINDER,RECTANGULAR BY FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>

void volume(float l);


void volume(float r,float h);
void volume(float a,float b,float c);

void main()
{
clrscr();
float l,r,h,a,b,c;
cout<<"\nEnter length of side of a cube :";
cin>>l;
volume(l);
cout<<"\nEnter base,radius and height of cylinder :";
cin>>r>>h;
volume(r,h);
cout<<"\nEnter length,width and height of a rectangular box :";
cin>>a>>b>>c;
volume(a,b,c);
[Link]();
[Link]();
}

void volume(float l)
{
cout<<"\nVolume of the cube :"<<(l*l*l);
}

void volume(float r,float h)


{
cout<<"\nVolume of the cylinder :"<<(3.14*r*r*h);
}

void volume(float a,float b,float c)


{
cout<<"\nVolume of rectangular box :"<<(a*b*c);
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 26/03/2021
//AIM : TO FIND ABSOLUTE VALUE OF INTEGER,REAL NUMBER
// AND COMPLEX NUMBER USING FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>
#include<math.h>

void absolute(int i);


void absolute(float r);
void absolute(float re,float im);

void main()
{
clrscr();
int i;float r,re,im; cout<<"\
nEnter any integer : "; cin>>i;
absolute(i);
cout<<"\nEnter any real number : ";
cin>>r;
absolute(r);
cout<<"\nEnter any real and imaginary part of any complex number : ";
cin>>re>>im;
absolute(re,im);
[Link]();
[Link]();
}

void absolute(int i)
{
cout<<"\nAbsolute value of given integer is : "<<fabs(i);
}

void absolute(float r)
{
cout<<"\nAbsolute value of given real number is : "<<fabs(r);
}

void absolute(float re,float im)


{
cout<<"\nAbsolute value of given complex number is : "<<sqrt((re*re)+(im*im));
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 26/03/2021
//AIM : TO FIND MINIMUM OF TWO AND THREE NUMBERS
// USING FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>

int minimum(int a,int b);


int minimum(int a,int b,int c);

void main()
{
clrscr();
int a,b,c,m1,m2;
cout<<"\nEnter any four integers : \n";
cin>>a>>b>>c;
m1=minimum(a,b);
m2=minimum(a,b,c);
cout<<"\nMinimum of first two numbers is : "<<m1;
cout<<"\nMaximum of three numbers is : "<<m2;
[Link]();
[Link]();
}

int minimum(int a,int b)


{
int mini;
mini=(a<b)?a:b;
return mini;
}

int minimum(int a,int b,int c)


{
int mini; mini=(a<b)?
a:b; mini=(mini<c)?
mini:c; return mini;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 27/03/2021
//AIM : TO INTERCHANGE TWO INTEGERS AND TWO REAL NUMBERS
// USING FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>

void interchange(int a,int b);


void interchange(float x,float y);

void main()
{
clrscr();
int a,b;
float x,y;
cout<<"\nEnter any two integers : \n";
cout<<"\n a = ";
cin>>a; cout<<"\
n b = "; cin>>b;
interchange(a,b);
cout<<"\nEnter any two real numbers : ";
cout<<"\n x = ";cin>>x;
cout<<"\n y = ";cin>>y;
interchange(x,y);
[Link]();
[Link]();
}

void interchange(int a,int b)


{
int k;
k=a;
a=b;
b=k;
cout<<"\nValue of integers after interchanging"
<<"\n a = "<<a<<" and b = "<<b;
}

void interchange(float x,float y)


{
float k;
k=x;
x=y;
y=k;
cout<<"\nValue of integers after interchanging"
<<"\n x = "<<x<<" and y = "<<y;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 27/03/2021
//AIM : TO FIND AVERAGE OF THREE INTEGERS AND THREE REAL NUMBERS
// USING FUNCTION OVERLOADING.

#include<iostream.h>
#include<conio.h>

float average(int a,int b,int c);


float average(float a,float b,float c);

void main()
{
clrscr();
int a,b,c;
float x,y,z,i,r;
cout<<"\nEnter any three integers : \n";
cout<<"\n a = ";cin>>a;
cout<<"\n b = ";cin>>b;
cout<<"\n c = ";cin>>c;
i=average(a,b,c);
cout<<"\nAverage of integers "<<a<<","<<b<<" and "<<c<<" = "<<i;
cout<<"\nEnter any three real numbers : ";
cout<<"\n x = ";cin>>x;
cout<<"\n y = ";cin>>y;
cout<<"\n z = ";cin>>z;
r=average(x,y,z);
cout<<"\nAverage of real numbers "<<x<<","<<y<<" and "<<y<<" = "<<r;
[Link]();
[Link]();
}

float average(int a,int b,int c)


{
return (a+b+c)/3;
}

float average(float x,float y,float z)


{
return (x+y+z)/3;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 26/03/2021
//AIM : TO FIND INTEGRATION OF `1/(1+x*x)' FROM `a' TO `b'
// USING TRAPEZOIDAL.

#include<iostream.h>
#include<conio.h>
#include<math.h>

float f(float x)
{
return (1/(1+pow(x,2)));
}

void main()
{
clrscr();
int n;
float a,b,x,sum=0,h,i,ans;
cout<<"\nEnter the values of limits of integration : ";
cout<<"\nLower limits : ";cin>>a;
cout<<"\nUpper limits : ";cin>>b; cout<<"\
nEnter number of subinterval : "; cin>>n;
h=(b-a)/n;
x=a+h;
while(x<b)
{
sum=sum+f(x);
x=x+h;
}
ans=(h/2)*(f(a)+f(b)+2*sum);
cout<<"\nApproximate value of given integral = "<<ans;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 26/03/2021
//AIM : TO FIND INTEGRATION OF `exp(x)' FROM `a' TO `b'
// USING TRAPEZOIDAL.

#include<iostream.h>
#include<conio.h>
#include<math.h>

double f(double x)
{
return (exp(x));
}

void main()
{
clrscr();
int n;
float a,b,x,sum=0,h,i,ans;
cout<<"\nEnter the values of limits of integration : ";
cout<<"\nLower limits : ";cin>>a;
cout<<"\nUpper limits : ";cin>>b; cout<<"\
nEnter number of subinterval : "; cin>>n;
h=(b-a)/n;
x=a+h;
while(x<b)
{
sum=sum+f(x);
x=x+h;
}
ans=(h/2)*(f(a)+f(b)+2*sum);
cout<<"\nApproximate value of given integral = "<<ans;
[Link]();
[Link]();
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11/03/2021
//AIM : TO INTERCHANGE TWO GIVEN NUMBERS USING REFERENCE VARIABLE.

#include<iostream.h>
#include<conio.h>

void interchange(int &x,int &y);

void main()
{
clrscr();
int a,b;
cout<<"\nEnter any two integers :";
cin>>a>>b;
cout<<"\nNumbers before interchanging :";
cout<<"\n a = "<<a<<", b = "<<b;
interchange(a,b);
cout<<"\nNumbers after interchanging :";
cout<<"\n a = "<<a<<", b = "<<b;
[Link]();
[Link]();
}

void interchange(int &x,int &y)


{
int c;
c=x;
x=y;
y=c;
}
// : Prabhat Singh
NAME : 201803380009874
// : 1
PRN : 11/03/2021
//AIM : TO INTERCHANGE TWO GIVEN NUMBERS USING REFERENCE POINTERS.

#include<iostream.h>
#include<conio.h>

void interchange(int*x,int *y);

void main()
{
clrscr();
int a,b;
cout<<"\nEnter any two integers :";
cin>>a>>b;
cout<<"\nNumbers before interchanging :";
cout<<"\n a = "<<a<<", b = "<<b;
interchange(&a,&b);
cout<<"\nNumbers after interchanging :";
cout<<"\n a = "<<a<<", b = "<<b;
[Link]();
[Link]();
}

void interchange(int *x,int *y)


{
int c;
c=*x;
*x=*y;
*y=c;
}

You might also like