Friday, February 15, 2019

self join in sql


                                                                                                                            edited by sukamal

create table dept(d_no varchar2(20) primary key,d_name varchar2(20),mg_no number);
insert into dept values('1','it','1');
insert into dept values('2','finance','3');

select *
from dept;

output:
D_NO
D_NAME
MG_NO
1
it
1
2
finance
3




2:code:
create table employee(e_id varchar2(20) primary key,e_name varchar2(20),d_no varchar2(20) references dept,city varchar2(20));


insert into employee values('1','ram','1','m.p');

insert into employee values('2','shyam','1','m.p');
insert into employee values('3','sita','2','u.p');
insert into employee values('4','gita','2','goa');
select *
from employee;
output:
E_ID
E_NAME
D_NO
CITY
1
ram
1
m.p
2
shyam
1
m.p
3
sita
2
u.p
4
gita
2
goa



3: Find the manager name of shyam.
Program code:
 select e_name
from employee
where e_id=(select mg_no from dept where d_no=(select d_no from employee where e_name='shyam'));
output:
E_NAME
ram

4:Find the employee city and manager city of all employee
Program code:
select e2.city,e1.city
from employee e1,dept,employee e2
where e2.d_no=dept.d_no and
dept.mg_no=e1.e_id;


output:
CITY
CITY
m.p
m.p
m.p
m.p
u.p
u.p
goa
u.p

5:Find the all employee name and their manager name.
Program code:
select e2.e_name,e1.e_name
from employee e1,dept,employee e2
where e2.d_no=dept.d_no and
dept.mg_no=e1.e_id;
output:
E_NAME
E_NAME

ram
ram

shyam
ram

sita
sita

gita
sita




6:Find all the employee
 whose city is equal to their manager city

program code:
select e2.e_name
from employee e1,dept,employee e2
where e2.d_no=dept.d_no and
dept.mg_no=e1.e_id and
e1.city=e2.city;

output:
E_NAME
ram
shyam
sita
    
    

Wednesday, February 13, 2019

DATE command in SQL

                                                                                             edited  by Sukamal
1:
 select sysdate
from dual
output:
SYSDATE
13-FEB-19

2:
select to_char(sysdate,'dd/mm/yy')
from dual
output:
TO_CHAR(SYSDATE,'DD/MM/YY')
13/02/19

3:
 select to_char(sysdate,'dd/mm/yyyy')
from dual
output:
TO_CHAR(SYSDATE,'DD/MM/YYYY')
13/02/2019

4:
select to_char(sysdate,'dy/mon/yyyy')
from dual
output:
TO_CHAR(SYSDATE,'DY/MON/YYYY')
wed/feb/2019

5:
select to_char(sysdate,'day/month/yyyy')
from dual
output:
TO_CHAR(SYSDATE,'DAY/MONTH/YYYY')
wednesday/february /2019

6:
select to_char(sysdate,'dd/mm/yy,hh:mi:ss')
from dual
output:
TO_CHAR(SYSDATE,'DD/MM/YY,HH:MI:SS')
13/02/19,02:48:55

7:
create table employee(id varchar2(20) primary key,name varchar2(20),dob date);
insert into employee values('1','vk',to_date('05/11/1988','dd/mm/yyyy'));
insert into employee values('2','msd',to_date('02/07/1982','dd/mm/yyyy'));
select *
from employee
output:

ID
NAME
DOB
2
msd
02-JUL-82
1
vk
05-NOV-88

8:Find the name of the employee who is younger than msd.

select name
from employee
where dob>(select dob from employee where name ='msd');
output:
NAME
vk

9:Find the name of employee who was born before 1985.

select name
from employee
where dob <to_date('1985','yyyy');
output:
NAME
msd

10:Find the name and month of dob of each employee.

 select name,to_char(dob,'mm') as month
from employee
output:
NAME
MONTH
msd
07
vk
11

11:Find the age of all employee.

select floor((sysdate-dob)/364.25)
from employee;
output:
FLOOR((SYSDATE-DOB)/364.25)
30
36


Thursday, December 27, 2018

CBCS C++ ASSIGNMENT

                                                                                             edited by TANIMA LODH & BKPAUL
ASSIGNMENT 1:

#include<iostream>
using namespace std;
class Area
{
private:
double l,b;
public:
Area(double x,double y)
{
l=x;
b=y;
}
void output()
{
cout<<"THE AREA OF THE RECTANGLE IS:"<<l*b;
}
};
int main()
{
double x,y;
cout<<"ENTER THE LENGTH AND THE BREADTH OF THE RECTANGLE: \n";
cin>>x>>y;
Area a(x,y);
a.output();
return 0;
}


OUTPUT:

ENTER THE LENGTH AND THE BREADTH OF THE RECTANGLE:
2.1
4.5
THE AREA OF THE RECTANGLE IS:9.45
--------------------------------
Process exited after 4.91 seconds with return value 0
Press any key to continue . . .

ASSIGNMENT 2:

#include<iostream>
#include<math.h>
using namespace std;
class Tri_Area
{
private:
double a,b,c;
public:
Tri_Area(double x, double y, double z)
{
a=x;
b=y;
c=z;
}
void output()
{
double s;
s=(a+b+c)/2;
cout<<"THE AREA OF THE TRIANGLE IS:"<<sqrt(s*(s-a)*(s-b)*(s-c));
}
};
int main()
{
cout<<"ENTER LENGTH OF THREE SIDES OF A TRIANGLE: \n";
double x,y,z;
cin>>x>>y>>z;
Tri_Area t(x,y,z);
t.output();
}

OUTPUT:

ENTER LENGTH OF THREE SIDES OF A TRIANGLE:
1.2
3.2
3.4
THE AREA OF THE TRIANGLE IS:1.91977
--------------------------------
Process exited after 13.29 seconds with return value 0
Press any key to continue . . .

ASSIGNMENT 3:

#include<iostream>
using namespace std;
class Distance
{
private:
int ft,in;

public:
Distance()
{
}
Distance(int f, int i)
{
ft=f;
in=i;
int r;
if(in>=12)
{
r=in/12;
in=in%12;
}
ft=ft+r;
}
void show_distance(Distance ob1,Distance ob2)
{
cout<<"THE 1st DISTANCE IS:"<<ob1.ft<<" feet "<<ob1.in<<" inches \n";
cout<<"THE 2nd DISTANCE IS:"<<ob2.ft<<" feet "<<ob2.in<<" inches \n";
}
void add(Distance ob1,Distance ob2)
{
Distance ob;
ob.ft=ob1.ft+ob2.ft;
ob.in=ob1.in+ob2.in;
if(ob.in>=12)
{
ob.in=ob.in-12;
ob.ft=ob.ft+1;
}
cout<<"THE RESULTANT DISTANCE IS:"<<ob.ft<<" feet "<<ob.in<<" inches";
}
};

int main()
{
int w,x,y,z;
cout<<"ENTER THE FEET AND INCHES OF 1ST DISTANCE: \n";
cin>>w>>x;
cout<<"ENTER THE FEET AND INCHES OF 2ND DISTANCE: \n";
cin>>y>>z;
Distance ob1(w,x), ob2(y,z),ob;
ob.show_distance(ob1,ob2);
ob.add(ob1,ob2);
}

OUTPUT:

ENTER THE FEET AND INCHES OF 1ST DISTANCE:
5
10
ENTER THE FEET AND INCHES OF 2ND DISTANCE:
9
17
THE 1st DISTANCE IS:5 feet 10 inches
THE 2nd DISTANCE IS:10 feet 5 inches
THE RESULTANT DISTANCE IS:16 feet 3 inches
--------------------------------
Process exited after 7 seconds with return value 0
Press any key to continue . . .

Assignment 4:

#include<iostream>
#include<string.h>
using namespace std;
class Student
{
private:
char name[20];
int marks1,marks2,marks3;
public:
Student()
{
cout<<"ENTER THE NAME: \n";
gets(name);
cout<<"ENTER THE MARKS: \n";
cin>>marks1>>marks2>>marks3;
}
void show_student()
{
cout<<"NAME:";
puts(name);
cout<<"MARKS OBTAINED BY "<<name<<" are: \n 1)"<<marks1<<"\n 2)"<<marks2<<"\n 3)"<<marks3<<endl;
}
void grade()
{
int avg=(marks1+marks2+marks3)/3;
if(avg>=80)
cout<<"GRADE A";
else
{
if(avg>=60)

cout<<"GRADE B";
else
{
if(avg>=40)
cout<<"GRADE C";
else
cout<<"FAIL";
}
}

}
};
int main()
{
Student s;
s.show_student();
s.grade();
}

Output :

ENTER THE NAME:
Tanima Lodh
ENTER THE MARKS:
98
95
93
NAME:Tanima Lodh
MARKS OBTAINED BY Tanima Lodh are:
 1)98
 2)95
 3)93
GRADE A
--------------------------------
Process exited after 15.88 seconds with return value 0
Press any key to continue . . .

Assignment 5:
#include<iostream.h>
class matrix
{
int mat[5][5],row,column;
public:
matrix(int,int);
matrix(matrix&);
void getdata();
matrix operator-(matrix);
matrix operator+(matrix);
matrix operator*(matrix);
void display();
};
matrix::matrix(int r,int c)
{
cout<<"constructor to initialize no. of rows and coloumns"<<endl;
row=r;
column=c;
}
matrix::matrix(matrix& m)
{
row=m.row;
column=m.column;
cout<<"copy constructor \n";
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
mat[i][j]=m.mat[i][j];
}
}
}
void matrix::getdata()
{
cout<<"value input: \n";
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
cout<<"value("<<i+1<<")("<<j+1<<"):";
cin>>mat[i][j];
}
}
}
matrix matrix::operator+(matrix a)
{
cout<<"addition operator \n";
matrix temp(row,column);
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
temp.mat[i][j]=mat[i][j]+a.mat[i][j];
}
}
return temp;
}
matrix matrix::operator-(matrix a)
{
cout<<"subtraction operator \n";
matrix temp(row,column);
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
temp.mat[i][j]=mat[i][j]-a.mat[i][j];
}
}
return temp;
}
matrix matrix::operator*(matrix a)
{
cout<<"multiplication operator \n";
matrix temp(row,column);
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
temp.mat[i][j]=0;
for(int k=0;k<column;k++)
{
temp.mat[i][j]=temp.mat[i][j]+(mat[i][k]*a.mat[k][j]);
}
}
}
return temp;
}
void matrix::display()
{
cout<<"the matrix is: \n";
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
cout<<mat[i][j]<<"\t";
}
cout<<endl;
}
}
void  main()
{
matrix m1(2,2),m2(2,2),m3(2,2);
m1.getdata();
m2.getdata();
m3=m1+m2;
m3.display();
m3=m1-m2;
m3.display();
m3=m1*m2;
m3.display();

}
Output:





Assignment 6:
#include<iostream.h>
#include<math.h>
class triangle
{
private:
int x1,y1,x2,y2,x3,y3;
public:
triangle(int a,int b, int c,int d,int e,int f)
{
x1=a; y1=b;  x2=c; y2=d; x3=e; y3=f;

}
void output()
{
double l1= sqrt((y2-y1)*(y2-y1)-(x2-x1)*(x2-x1));
double l2=sqrt((y3-y2)*(y3-y2)-(x3-x2)*(x3-x2));
double l3=sqrt((y1-y3)*(y1-y3)-(x1-x3)*(x1-x3));
if(l1==l2 && l2==l3)
{
cout<<"equilateral";
}
else
{
if(l1==l2||l1==l3)
{
cout<<"isosceles";
}
else
{
cout<<"scalene";
}
}
}
~triangle(){}
};
void main()
{
int a,b,c,d,e,f;
cout<<"enter the coordinates of the 1st triangle:";
cin>>a>>b;
cout<<"enter the coordinates of the 2nd triangle:";
cin>>c>>d;
cout<<"enter the coordinates of the 3rd triangle:";
cin>>e>>f;
triangle t(a,b,c,d,e,f);
t.output();
}
Output:




Assignment 7:
#include<iostream.h>
#include<math.h>
class polar
{
private:
int r, theta;
public:
void input()
{
cout<<"enter the polar coordinates of the point: \n";
cin>>r>>theta;
}
double getx()
{
return r*cos(theta);
}
  double gety()
{
return r*sin(theta);
}
void display()
{
cout<<"radius="<<r<<endl<<"angle="<<theta;
}
polar operator+(polar p)
{
double x=getx()+p.getx();
double y=gety()+p.gety();
 polar temp;
double z=sqrt(x*x+y*y);
double a=atan(y/x);
temp.r=z;
temp.theta=a;
return temp;
}
};
void main()
{
polar p1,p2,p3;
p1.input();
p2.input();
p3=p1+p2;
p3.display();
}
Output:




Assignment 8:
#include<iostream.h>
class fraction
{
private:
int n,d;
public:
void input()
{
cout<<"enter the numerator of the fraction: \n";
cin>>n;
cout<<"enter the denominator of the fraction: \n";
cin>>d;
}
fraction operator+(fraction f)
{
fraction temp1;
temp1.d=d*f.d;
temp1.n=n*f.d+f.n*d;
return temp1;
}
fraction operator-(fraction f)
{
fraction temp2;
temp2.d=d*f.d;
temp2.n=n*f.d-f.n*d;
return temp2;
}
void display();

};
void fraction::display()
{    int cf;
if(n>0 && d>0)
{
for(int i=1;i<=n && i<=d;i++)
{
  if(n%i==0&&d%i==0)
  {
  cf=i;
  }
}
cout<<"the fraction is:"<<endl<<n/cf<<"/"<<d/cf<<endl;
}
if(n<0)
{
n=n*(-1);
 for(int i=1;i<=n && i<=d;i++)
{
  if(n%i==0&&d%i==0)
  {
  cf=i;
  }
}
cout<<"the fraction is:"<<endl<<"-"<<n/cf<<"/"<<d/cf<<endl;
}
}
void main()
{
fraction f1,f2,f3,f4;
f1.input();
f2.input();
f1.display();
f2.display();
f3= f1+f2;
cout<<"after addition \n";
f3.display();
 f4= f1-f2;
cout<<"after subtraction \n";
f4.display();
}
Output:





Assignment 11:
#include<iostream.h>
class bit_op
{
private:
int a,b;
public:
bit_op(int x,int y)
{
  a=x;
  b=y;
}
void bit_and()
{
int m=a&b;
cout<<a<<" AND "<<b<<"="<<m<<endl;
}
void bit_or()
{
int n=a|b;
cout<<a<<" OR "<<b<<"="<<n<<endl;
}
void bit_xor()
{
int o=a^b;
cout<<a<<" XOR "<<b<<"="<<o<<endl;
}
};
void main()
{
cout<<"enter two integers"<<endl;
int x,y;
cin>>x>>y;
bit_op b(x,y);
b.bit_and();
b.bit_or();
b.bit_xor();
}
Output:



Saturday, August 5, 2017

8085 assignment list



1.  Add two 8 bit data,result 16 bit.
2.  Add two 16 bit numbers,result 16 bit.
3.  Subtract  two 16 bit numbers,result 16 bit.
4. Add two 8 bit decimal  number, result 16 bit
5. 8 bit decimal subtraction
6. find all flags after inr b, and save it in B register
7. 2’s complement of a number,16bit
8. Add content of two memory location
9. 8 bit data shift right,1bit
10. 8 bit data shift left,1bit
11. 16 bit data shift right,1bit
12. 16 bit data shift left,1bit
13. sum of n numbers , result 16bit
14. data transfer from one memory block to another
15. max from set of  n numbers
16. min from set of n numbers
17. linear search
18. 2nd highest from n numbers
19. multiply using repeated addition
20. multiply using add ­shift
21. count all even numbers and odd numbers
22. count positive ,negative,zero from n numbers
22. division 16 bit data by 8 bit
23. BCD addition
24. BCD subtraction
25. factorial of a number
26. fibonacci series
27. calculate number of ones and zeros in a 8 bit number
28. calculate number of ones and zeros in a 16 bit number
29. Ascending order sorting
30. descending order sorting
31. multibyte addition
32. multibyte decimal addition
33. sum of series multibyte addition
34. multibyte subtraction
35. function ­ addition,subtraction,multiply,division,square,sorting.
36. half adder and full adder
37. z= 2.A.B+C.D/4B   
38. 8 bit number palindrome checking
39. square root of number
40. merge two sorted list
41. binary code to gray code
42. gray code to binary code