Monday, 25 March 2024

System Details using Oracle ( RDBMS )

select sysdate from dual;

select to_char(sysdate,'yyyy') from dual;

select to_char(sysdate,'yyy') from dual;

select to_char(sysdate,'yy') from dual;

select to_char(sysdate,'mm') from dual;

select to_char(sysdate,'mon') from dual;

select to_char(sysdate,'month') from dual;

select to_char(sysdate,'q') from dual;

select to_char(sysdate,'rm') from dual;

select to_char(sysdate,'dd') from dual;

select to_char(sysdate,'ddd') from dual;

select to_char(sysdate,'d') from dual;

select to_char(sysdate,'day') from dual;

select to_char(sysdate,'dy') from dual;

select to_char(sysdate,'hh') from dual;

select to_char(sysdate,'hh24') from dual;

select to_char(sysdate,'mi') from dual;

select to_char(sysdate,'ss') from dual;

select to_char(sysdate,'dd/mm/yy') from dual;

select to_char(sysdate,'dd-mm-yy') from dual;


create table EMP1(eid number,ename varchar2(10),dob date);

desc EMP1;

insert into EMP1 values(7,'dhoni','07-JUL-1981');

select * from EMP1;

insert into EMP1 values(99,'sourav','08-JUL-1972');

insert into EMP1 values(45,'jyotibasu','08-JUL-1914');

select * from EMP1;


select ename,to_char(dob,'yyyy') from EMP1;

select ename,to_char(dob,'dd/mm/yy') from EMP1;


insert into EMP1 values(1,'arik',to_date('15/11/2003','dd/mm/yyyy'));

insert into EMP1 values(2,'pranjali',to_date('13/12/2003','dd/mm/yyyy'));

Tuesday, 27 February 2024

Student Table Creation in Oracle

create table student(roll number,name varchar2(10),address varchar2(50));
insert into student values(2,'jaggu','goa');
insert into student values(1,'chutki','u.p');
insert into student values(5,'bheem','m.p');
select *
from student;
select name
from student;
select name,address
from student;
drop table student;

Saturday, 23 December 2023

Employee Table Using Nested Query

create table EMP(eid number, ename varchar2(20),age number,salary number,company varchar2(60));
insert into EMP values (1,'raju',30,30000,'TCS');
insert into EMP values (2,'indu',35,40000,'IBM');
insert into EMP values (3,'kalia',40,50000,'CTS');
select *
from EMP;
drop table EMP;

select * 
from EMP
where company='TCS';

select ename 
from EMP
where salary>=40000;

select ename 
from EMP
where age<=35 and salary>=40000;

select ename 
from EMP
where age<=35 or salary>=40000;

select min(salary)
from EMP;

select min(salary) as minimum_salary
from EMP;

select max(salary)
from EMP;

select max(salary) as maximum_salary
from EMP;

select avg(salary)
from EMP;

select avg(salary) as average_salary
from EMP;

select ename
from EMP
where salary=(select max(salary)
                from EMP);

select ename
from EMP
where salary=(select min(salary)
                from EMP);

select ename
from EMP
where salary>=(select avg(salary)
                from EMP);

select ename
from EMP
where age=(select max(age)
                from EMP);

select ename
from EMP
where salary>(select salary
                from EMP
                where ename='raju');

Friday, 22 December 2023

FCFS Scheduling in OS

 #include <stdio.h>

int main()

{

    int pid[15];

    int bt[15];

    int n,i;

    printf("Enter the number of processes: ");

    scanf("%d",&n);

 

    printf("Enter process id of all the processes: ");

    for(i=0;i<n;i++)

    {

        scanf("%d",&pid[i]);

    }

 

    printf("Enter burst time of all the processes: ");

    for( i=0;i<n;i++)

    {

        scanf("%d",&bt[i]);

    }

 

    int wt[n];

    wt[0]=0;

 

    //for calculating waiting time of each process

    for(i=1; i<n; i++)

    {

        wt[i]= bt[i-1]+ wt[i-1];

    }

 

    printf("Process ID     Burst Time     Waiting Time     TurnAround Time\n");

    float twt=0.0;

    float tat= 0.0;

    for(i=0; i<n; i++)

    {

        printf("%d\t\t", pid[i]);

        printf("%d\t\t", bt[i]);

        printf("%d\t\t", wt[i]);

 

        //calculating and printing turnaround time of each process

        printf("%d\t\t", bt[i]+wt[i]);

        printf("\n");

 

        //for calculating total waiting time

        twt += wt[i];

 

        //for calculating total turnaround time

        tat += (wt[i]+bt[i]);

    }

    float att,awt;

 

    //for calculating average waiting time

    awt = twt/n;

 

    //for calculating average turnaround time

    att = tat/n;

    printf("Avg. waiting time= %f\n",awt);

    printf("Avg. turnaround time= %f",att);

}

SJF Scheduling in OS

 #include<stdio.h>

int main()

{

    int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,totalT=0,pos,temp;

    float avg_wt,avg_tat;

    printf("Enter number of process:");

    scanf("%d",&n);

 

    printf("\nEnter Burst Time:\n");

    for(i=0;i<n;i++)

    {

        printf("p%d:",i+1);

        scanf("%d",&bt[i]);

        p[i]=i+1;

    }

 

    //sorting of burst times

    for(i=0;i<n;i++)

    {

        pos=i;

        for(j=i+1;j<n;j++)

        {

            if(bt[j]<bt[pos])

                pos=j;

        }

 

        temp=bt[i];

        bt[i]=bt[pos];

        bt[pos]=temp;

 

        temp=p[i];

        p[i]=p[pos];

        p[pos]=temp;

    }

 

    wt[0]=0;

 

    //finding the waiting time of all the processes

    for(i=1;i<n;i++)

    {

        wt[i]=0;

        for(j=0;j<i;j++)

             //individual WT by adding BT of all previous completed processes

            wt[i]+=bt[j];

 

        //total waiting time

        total+=wt[i];   

    }

 

    //average waiting time

    avg_wt=(float)total/n;  

 

    printf("\nProcess\t Burst Time \tWaiting Time\tTurnaround Time");

    for(i=0;i<n;i++)

    {

        //turnaround time of individual processes

        tat[i]=bt[i]+wt[i]; 

 

        //total turnaround time

        totalT+=tat[i];      

        printf("\np%d\t\t %d\t\t %d\t\t\t%d",p[i],bt[i],wt[i],tat[i]);

    }

 

    //average turnaround time

    avg_tat=(float)totalT/n;     

    printf("\n\nAverage Waiting Time=%f",avg_wt);

    printf("\nAverage Turnaround Time=%f",avg_tat);

}

Sunday, 17 December 2023

Singly Linked list insert-delete-display-search-count

 #include<iostream>

using namespace std;

class Node

{

public:

int data;

Node *link;

};

class LinkedList

{

Node *head;

public:

LinkedList();

void myInsertBeg();

void myInsertEnd();

void myInsertPos(int p);

void myDeleteBeg();

void myDeleteEnd();

void myDeletePos(int p);

void mySreach();

void myCount();

void myShow();

};

LinkedList::LinkedList()

{

head=NULL;

}

void LinkedList::myInsertBeg()

{

Node *temp;

int n;

temp=new Node();

cout<<"Enter the value to insert: ";

cin>>n;

temp->data=n;

if(head==NULL)

{

temp->link=NULL;

head=temp;

}

else

{

temp->link=head;

head=temp;

}

}

void LinkedList::myInsertEnd()

{

Node *temp,*h;

int n;

temp=new Node();

cout<<"Enter the value to insert: ";

cin>>n;

temp->data=n;

temp->link=NULL;

h=head;

while((h->link)!=NULL)

{

h=h->link;

}

h->link=temp;

}

void LinkedList::myInsertPos(int p)

{

Node *temp,*h;

int n,c=1;

temp=new Node();

cout<<"Enter the value to insert:";

cin>>n;

temp->data=n;

h=head;

while(c<(p-1))

{

h=h->link;

c++;

}

temp->link=h->link;

h->link=temp;

}

void LinkedList::myDeleteBeg()

{

head=head->link;

cout<<"First element is deleted.";

}

void LinkedList::myDeleteEnd()

{

Node *h;

h=head;

while(((h->link)->link)!=NULL)

{

h=h->link;

}

h->link=NULL;

cout<<"Last element is deleted.";

}

void LinkedList::myDeletePos(int p)

{

Node *h;

h=head;

int c=1;

while(c<(p-1))

{

h=h->link;

c++;

}

h->link=(h->link)->link;

cout<<"The element is deleted.";

}

void LinkedList::mySreach()

{

Node *h;

h=head;

int num,c=1;

cout<<"Enter the value which you want to search:";

cin>>num;

while((h->link)!=NULL)

{

if((h->data)==num)

{

cout<<"The number is found at position:"<<c;

}

h=h->link;

c++;

}

if((h->data)==num)

{

cout<<"The number is found at position:"<<c;

}

else

{

cout<<"The number is not present in the linkedlist.";

}

}

void LinkedList::myShow()

{

Node *h;

h=head;

while(h!=NULL)

{

cout<<h->data<<" ";

h=h->link;

}

}

void LinkedList::myCount()

{

Node *h;

h=head;

int count=0;

while((h->link)!=NULL)

{

count++;

h=h->link;

}

cout << "Count of nodes is " <<++count;

}


int main()

{

LinkedList ob;

int a=0,b,pos;

while(a==0)

{

cout<<"\n--menu--\n1.add at the beg\n2.add at the end\n3.add at a position\n";

cout<<"4.delete from begining\n5.delete from end\n6.delete at a position\n";

cout<<"7.search\n8.count\n9.show\n10.exit\n";

cout<<"Enter your option:";

cin>>b;

switch(b)

{

case 1:

ob.myInsertBeg();

break;

case 2:

ob.myInsertEnd();

break;

case 3:

cout<<"Enter the position where you want to insert:";

cin>>pos;

ob.myInsertPos(pos);

cout<<"The value is inserted successfully.";

break;

case 4:

ob.myDeleteBeg();

break;

case 5:

ob.myDeleteEnd();

break;

case 6:

cout<<"Enter the position where you want to delete:";

cin>>pos;

ob.myDeletePos(pos);

break;

case 7:

ob.mySreach();

break;

case 8:

ob.myCount();

break;

case 9:

ob.myShow();

break;

default:

if(b==10)

{

a=1;

    cout<<"You are exit from the porgram!";

}

else

{

cout<<"You enter wrong option!";

}

}

}

}

There is no UNIVERSAL PERFECT RULE !

  Yes. Looking across the themes we've discussed, the main topics that seemed to frustrate you or pull you into repeated optimization w...