Sei sulla pagina 1di 4

program 5

//todisplay a functioning 4 function calculater//


#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
void main()
{float A,S,D,M;
int a,b,c;
cout<<"enter the values of 2 numbers";
cin>>a>>b;
cout<<"choose your option \n 1.addition \n 2.subtraction \n 3.division \n 4.mult
iplication";
cin>>c;
switch(c)
{case'1':cout<<"your choice was addition";
A=a+b;
cout<<A;
break;
case'2':cout<<"your choice was subtraction";
if(a>b)
S=a-b;
else S=b-a;
cout<<S;
break;
case'3':cout<<"your choice was division";
D=a/b;
cout<<"";
cout<<D;
break;
case'4':cout<<"your choice was multiplication";
M=a*b;
cout<<"";
cout<<M;

break;
default :"wrong choice entered" ;
}
getch();
}
PROGRAMME 10
find a number form an array
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int A[20],m,n,i;
cout<<"enter the value of n";
cin>>n;
cout<<"start entering"<<n<<"numbers";
for(i=0;i<n;i++)
cin>>A[i];
cout<<"\n enter a number to be searched";
cin>>m;
for(i=0;i<n;i++)
if(m==A[i])
{cout<<"element found in array and is the element" ;
cout<<(i+1)<<"of array";goto x;

}
cout<<"element not found in the list";
x: getch();
}
programm 14
to find whether a matrix is symmetric or not
#include<iostream.h>
#include<conio.h>
void main()
{int A[10][10],i,j,n,m,p=1;
cout<<"enter order of matrix";
cin>>m>>n;
cout<<"enter the matrix";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>A[i][j];
if(m==n)
{for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(A[i][j]!=A[j][i])
{p=0;
break;
for(i=0;i<m;i++)
cout<<A[i][j]<<"\t";
cout<<"\n";}
else cout<<"wrong order of matrix";}
getch();
}
PROGRAM 15
to add two matrix
#include<iostream.h>
#include<conio.h>
void main()
{int a[10][10],b[10][10],c[10][10];
int i,j,m,n,p,q ;
cout<<" enter the order of matrix A";
cin>>m>>n;
cout<<"\n enter the order of matrix B:";
cin>>p>>q;
if((m==p)&&(n==p))
{cout<<"\n input matrix -a: \n";
for(i=0;i<m;i++)
for(j=0;i<n;j++)
cin>>a[i][j];
cout<<"\n input matrix-b: \n";
for(i=0;i<p;i++)
for(j=0;j<q;j++)
cin>>b[i][j];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
cout<<"\n the sum of matrix A and B is : \n";

for(i=0;j<m;i++)
{cout<<"\n";
for(j=0;j<n;j++)
cout<<""<<c[i][j];
}
}
else
{cout<<"\n wrong order of matrix ";}
getch();
}

program 17
to find the product of two matix
#include<iostream.h>
#include<conio.h>
void main()
{int A[10][10],B[10][10],C[10][10],c,i,j,m,n,p,q;
cout<<"\n enter the order of matrix 1";
cin>>m>>n;
cout<<"\n enter the order of matrix 2";
cin>>p>>q;
cout<<"enter the elements of matrix 1";
for(i=0;i<m;i++)
for(j=0;j<n;i++)
cin>>A[i][j];
cout<<"enter the elements of matrix 2";
for(i=0;i<p;i++)
for(j=0;j<q;j++)
cin>>B[i][j];
if(n==p)
{for(i=0;i<m;i++)
for(j=0;j<n;j++)
{C[i][j]=0;
for(int k=0;k<n;k++)
C[i][j]=A[i][k]*B[k][j];
}
cout<<"in matrix1:";
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
cout<<A[i][j]<<"\t";
cout<<"\n";
}
cout<<"\n matrix 2:";
for(i=0;i<p;i++)
{for(j=0; j<q;j++)
cout<<C[i][j]<<"\t";
cout<<"\n";
}
getch();
}}

PROGRAM 20
STRUCTURE OF EMPLOYEES

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct employee
{int eno;
char ename[50];
char designation[50];
float basic;
float netsal;
};
void main()
{float DA,HRA,gross,PF;
cout<<"\n input employee info";
employee e1;
cout <<"\n enter employee no:";
cin>>e1.eno;
cout<<"enter employee name";
gets(e1.ename);
cout<<"enter employees designation";
gets(e1.designation);
cout<<"enter basic salary";
cin>>e1.basic;
DA=0.3*e1.basic;
HRA=0.2*e1.basic;
gross=e1.basic+DA+HRA;
PF=0.12*gross;
e1.netsal=gross-PF;
cout<<"employee no: "<<e1.eno;
cout<<"\n";
cout<<"employee name:"<<e1.ename;
cout<<"\n employee designation:"<<e1.designation;
cout<<"in net salary: "<<e1.netsal;
getch();
}

Potrebbero piacerti anche