Practical File
Practical File
//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>
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>
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]();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,ans;
cout<<"\nEnter any three numbers : ";
cin>>a>>b>>c;
minimum(a,b,c);
[Link]();
[Link]();
}
#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>
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]();
}
#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>
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]();
}
#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 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 main()
{
clrscr();
float b,h;
cout<<"\nEnter the base and height of a triangle respectively : ";
cin>>b>>h;
area(b,h);
[Link]();
[Link]();
}
#include<iostream.h>
#include<conio.h>
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]();
}
#include<iostream.h>
#include<conio.h>
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>
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>
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 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 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 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 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 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 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 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;
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);
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);
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;
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 main()
{
clrscr();
addition();
average();
[Link]();
[Link]();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float x,y;
cout<<"\nEnter any two numbers : ";
cin>>x>>y;
addition(x,y);
average(x,y);
[Link]();
[Link]();
}
#include<iostream.h>
#include<conio.h>
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]); }
#include<iostream.h>
#include<conio.h>
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]); }
#include<iostream.h>
#include<conio.h>
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]();
}
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>
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]();
}
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 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]();
}
#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 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 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 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 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 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<<")";
}
#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<<")";
}
#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 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<<")";
}
#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";
}
}
#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);
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";
}
}
#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";
}
}
#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";
}
}
#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";
}
}
#include<iostream.h>
#include<conio.h>
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]();
}
#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";
}
}
#include<iostream.h>
#include<conio.h>
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]();
}
#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<<")";
}
#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<<")";
}
#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<<")";
}
#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<<")";
}
#include<iostream.h>
#include<conio.h>
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]();
}
#include<iostream.h>
#include<conio.h>
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);
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
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);
}
#include<iostream.h>
#include<conio.h>
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]();
}
#include<iostream.h>
#include<conio.h>
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]();
}
#include<iostream.h>
#include<conio.h>
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]();
}
#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 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]();
}
#include<iostream.h>
#include<conio.h>
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]();
}