Monday 29 October 2012

Priority Sheduling in C

#include<conio.h>
#include<stdio.h>
void main()
 {
   clrscr();
   int x,n,p[10],pp[10],pt[10],w[10],t[10],i;
   float atat,awt;
   printf("Enter the number of process : ");
   scanf("%d",&n);

   for(i=0;i<n;i++)
    {
      printf("\nProcess no %d : ",i+1);
      printf("\nenter process burst time:");
      scanf("%d" ,&pt[i]);
      printf("enter proccess priority");
      scanf("%d",&pp[i]);
      p[i]=i+1;
    }
  for(i=0;i<n-1;i++)
   {
     for(int j=i+1;j<n;j++)
     {
       if(pp[i]>pp[j])
       {
     x=pp[i];
     pp[i]=pp[j];
     pp[j]=x;
     x=pt[i];
     pt[i]=pt[j];
     pt[j]=x;
     x=p[i];
     p[i]=p[j];
     p[j]=x;
      }
   }
}
w[0]=0;
awt=0;
t[0]=pt[0];
atat=t[0];
for(i=1;i<n;i++)
 {
   w[i]=t[i-1];
   awt+=w[i];
   t[i]=w[i]+pt[i];
   atat+=t[i];
 }
printf("\n\n Job \t Burst Time \t Wait Time \t Turn Around Time   Priority \n");
for(i=0;i<n;i++)
  printf("\n %d \t\t %d  \t\t %d \t\t %d \t\t %d \n",p[i],pt[i],w[i],t[i],pp[i]);
awt/=n;
atat/=n;
printf("\n Average Wait Time : %4f \n",awt);
printf("\n Average Turn Around Time : %4f \n",atat);
getch();
}











Saturday 21 April 2012

A Menu Based Program in shell script & Creating Backup of Home directory


1. The menu application should have at least four choices.
2. One of the choices should allow the user of the application to backup all of the files in their home directory into a special “backup” directory.
If the “backup” directory does not exist, your script should create it.
If the “backup” directory is not empty, display a message to the user that it is not empty, ask the user if they want to delete all the files. If they say yes, delete the files and perform the backup. If they say no, display a message that the backup was not performed.
3. One of the choices should display the current date and time.
4. One of the choices should display the current month calendar.
5. One of the choices should be the execution of a command that is often used.
6. If the choice is invalid, redisplay the menu.




Desgined Code:-
#! bin/bash

#menu

echo enter [1] to backup                                                        

echo enter [2] to see  current date and time

echo enter [3] to see current month calender

echo enter [4] to execute the command

read a                 # a is the variable to store 1,2,3,4....

case "$a" in

1)cd /                # change dir to root

cd /home/saurabh      # change dir to home/saurabh

mkdir backup          # make a dir named backup in home/saurabh

cd backup             # change dir to backup

[ "$(echo .* *)" == ". .. *" ] && a=0||a=1      # it searches files and folder in backup dir if there is no files and folders

                                                #  then a is set to 0, if it contains then a is set to one



if [ $a -eq 0 ]                                 # if a=0 then display backup directory is empty

then

echo backup directory is empty

fi

if [ $a -eq 1 ]                                 # if a=1 then display backup directory has files

then

echo backup directory has files

echo if you want to remove all the files enter 1 if not enter any another no.

read b             # b is a variable to store a no.

if [ $b -eq 1 ]

then

rm -r *            # it removes all the files and folder from backup dir.

fi
[ "$(echo .* *)" == ". .. *" ] && echo now dir is empty|| echo dir is non empty  
#if backup dir has files and    folder then it shows dir is non empty

#if backup dir has no files and folder then it shows dir is empty
                 
fi

echo enter 5 to backup your all files and folder if you dont want.... enter any other no.

read c           # c is a variable to store a no.

if [ $c -eq 5 ]

then

cd /            # change dir to root

cp -r home home/saurabh/backup 
# copy all the files and folder of home to home/saurabh/backup
fi ;;


2) echo todays date and time is $(date);; # shows todays date and time

3) cal ;;                                 # shows calender of month

4) touch sau.c;;                          #create a file...

*) bash menu.sh;;                         # redisplay the menu after entering any other no. other than 1,2,3,4

esac

Input:-
bash menu.sh

Output#1:-
enter [1] to backup

enter [2] to see current date and time

enter [3] to see current month calender

enter [4] to execute the command

1
backup directory is empty

enter 5 to backup your all files and folder if you dont want.... enter any other no.
5
All the files and folder of home directoty will be copied & stored to home/saurabh/backup
directory.
Output#2:-
enter [1] to backup

enter [2] to see current date and time

enter [3] to see current month calender

enter [4] to execute the command

2   
todays date and time is Sun Apr 15 13:29:12 IST 2012


Output#3:-
enter [1] to backup

enter [2] to see current date and time

enter [3] to see current month calender

enter [4] to execute the command

3

     April 2012

Su Mo Tu We Th Fr Sa

 1  2  3  4  5  6  7

 8  9 10 11 12 13 14

15 16 17 18 19 20 21

22 23 24 25 26 27 28

29 30


Output#4:-

enter [1] to backup

enter [2] to see current date and time

enter [3] to see current month calender

enter [4] to execute the command

8      

enter [1] to backup

enter [2] to see current date and time

enter [3] to see current month calender

enter [4] to execute the command



 Limitations:-
To backup the files of Home directory all the files should have read permissions for all user group and others...otherwise it will show permission denied.


When I excuted the program I got errors as:-

cp: cannot stat `home/saurabh/Desktop/assignment/shell/modes/f1': Permission denied

cp: cannot stat `home/saurabh/Desktop/assignment/shell/modes/modes.sh': Permission denied

cp: cannot stat `home/saurabh/Desktop/assignment/change/f1': Permission denied

cp: cannot stat `home/saurabh/Desktop/assignment/change/d1': Permission denied


 References:-
Beginning Linux Programming(Text Book)


Tuesday 10 April 2012

File Management System In Shell Script



echo------------------------------FILE MANAGEMENT SYSTEM--------------------------------------------
echo give a path of folder which contain some files:
cd /
read a
cd $a
echo enter 1 to List files stored along with their sizes.
echo enter 2 to Create files
echo enter 3 to Allow changes to files
echo enter 4 to Delete files
echo enter 5 to store information of files
echo enter 6 to move files between the directories
read n
case "$n" in


1) ls -s;;
2) echo enter file_name and write in file
   read f
   cat> $f;;
3) echo give path of folder to make changes in the files
   read c
   cd /
   cd $c
   echo folder contain files:-
   ls
   echo give the name of file you want to make changes
   read d
   echo "enter 1 for read,write,execute to user group and others"
   echo "enter 2 for read and write to users and group"
   echo "enter 3 for read write and execute to only users"
   read m
   case "$m" in
   1) chmod 777 $d;;
   2) chmod 660 $d;;
   3) chmod 700 $d;;
   esac
   echo changes happened:-
   ls -l;;
4) echo files are:-
   ls
   echo enter no. of files you want to delete
   read countt
   for(( i=1 ; i<=$countt ; i++ ))
   do
   echo give filename to delete
   read e
   rm -r $e
   echo file $e is deleted
   echo now files are:-
   ls
   done;;


5) echo files are:-
   ls
   echo enter name of file you want to see the information and store it in status file.
   read g
   echo information of file is:
   stat $g
   touch status
   stat $g>>status
   echo information of file is stored in file name status and its path is $a/status;;


6) echo enter the path of source directory from where you want to copy the files:
   read p
   echo enter the path of destination directory to where you want to move the files:
   read q
   cd /
   cd $p
   echo files of source dir are:-
   ls
  
   echo enter no. of files you want to move.
   read count
   for(( i=1 ; i<=$count ; i++ ))
   do
   cd /
   cd $p
   echo files of source dir are:-
   ls
   echo enter the name of file you want to move
   read name
   mv /$p/$name  /$q
   cd /
   cd $q
   echo content of destination dir $q now are:
   ls
   done ;;
  
esac

Note:- To run the program save it as filename.sh and give a command bash filename.sh






Sunday 8 April 2012

Gauss Seidal Method in C to solve equations.

Applied Gauss Seidal method to solve following system of equation up to given no. of iterations.
(1) 4x+y-z=7
(2) 2x+3y+z=4
(3) x+y-2z=2

#include<conio.h>
#include<stdio.h>
void main()
{
float x,y,z,a,b,c;
int i,n;
clrscr();
printf("enter no of iteration n");
scanf("%d",&n);
x=0;
y=0;
z=0;
a=(7-y+z)/4;
b=(4-(2*a)-z)/3;
c=((-1)*(2-a-b))/2;
printf("x            y           z");
printf("\n%f  %f  %f",a,b,c);
x=a;
y=b;
z=c;
for(i=1;i<n;i++)
{
x=(7-y+z)/4;
y=(4-(2*x)-z)/3;
z=(-1)*(2-x-y)/2;
printf("\n%f  %f  %f ",x,y,z);
}
getch();
}




Saturday 17 March 2012

Library Management System in C++


#include<iostream.h>
#include<conio.h>
int a=2,b=3,c=4,i=0;
class lib
{
int n;
public:

void issue();
void show();
void ret();
};

 void lib::issue()
{                                                               
cout<<"enter code:";
cin>>n;


switch(n)
{
case 101:
if(a!=i)
{
a--;
cout<<"morish mano is issued\nno. of books="<<a<<"\n\n";

}
break;
case 102:
if(b!=i)
{
b--;
cout<<"peter syckes is issued\n no. of book="<<b<<"\n\n";

}
break;
case 103:
if(c!=i)
{
c--;
cout<<"ncert maths is issued\n no. of book="<<c<<"\n\n";

}
break;
}
}
void lib::ret()
{
cout<<"enter code to return the book:";
cin>>n;


switch(n)
{
case 101:
if(a!=2)
{
a++;
cout<<"morish mano is returned\nno. of books="<<a;

}
break;
case 102:
if(b!=3)
{
b++;
cout<<"peter syckes is returned\n no. of book="<<b;

}
break;
case 103:
if(c!=4)
{
c++;
cout<<"ncert maths is returned\n no. of book="<<c;

}
break;
}
}

void lib::show()
{
cout<<"book code:101\n";
cout<<"name: morish mano\n";
cout<<"availability:"<<a<<"\n\n";
cout<<"book code:102\n";
cout<<"name: peter sykes\n";
cout<<"availability:"<<b<<"\n\n";
cout<<"book code:103\n";
cout<<"name: ncert maths\n";
cout<<"availability:"<<c<<"\n\n";
}
void main()
{
class lib lb;
int k,m;
clrscr();
x:
cout<<"enter 1 to see the list of books\n";
cout<<"enter 2 to issue the book\n";
cout<<"enter 3 to return the book\n";
cout<<"number:";
cin>>k;
switch(k)
{
case 1:
lb.show();
cout<<"\nenter 0 to go to previous:";
cin>>m;
if(m==0)
goto x;
else
break;
case 2:
lb.issue();
cout<<"\nenter 0 to go to previous:";
cin>>m;
if(m==0)
goto x;
else
break;
case 3:
lb.ret();
cout<<"\nenter 0 to go to previous:";
cin>>m;
if(m==0)
goto x;
else
break;
}
getch();
}

University Management System in C++


#include<iostream.h>
#include<conio.h>                                                                                        
int a=2,b=3,c=4,i=0;
class lib
{
int bookid,n;
public:
void show();
void issue();
void ret();
};
class lib lb;
void lib::issue()
{
cout<<"enter code:";                                                                             
cin>>n;                                                                            
switch(n)
{
case 101:
if(a!=i)
{
a--;
cout<<"morish mano is issued\nno. of books="<<a<<"\n\n";
}
else
cout<<"book is not available in library\n";

break;
case 102:
if(b!=i)
{
b--;
cout<<"peter syckes is issued\n no. of book="<<b<<"\n\n";
}
else
cout<<"book is not available in library\n";
break;
case 103:
if(c!=i)
{
c--;
cout<<"ncert maths is issued\n no. of book="<<c<<"\n\n";
}
else
cout<<"book is not available in library\n";
break;
}
}
void lib::ret()
{
cout<<"enter book code to return the book:";
cin>>n;


switch(n)
{
case 101:
if(a!=2)
{
a++;
cout<<"morish mano is returned\nno. of books="<<a<<"\n";

}
else
cout<<"you have not issued this book\n";
break;
case 102:
if(b!=3)
{
b++;
cout<<"peter syckes is returned\n no. of book="<<b<<"\n";
}
else
cout<<"you have not issued this book\n";
break;
case 103:
if(c!=4)
{
c++;
cout<<"ncert maths is returned\n no. of book="<<c<<"\n";
}
else
cout<<"you have not issued this book\n";
break;
}
}

void lib::show()
{
cout<<"book code:101\n";
cout<<"name: morish mano\n";
cout<<"availability:"<<a<<"\n\n";
cout<<"book code:102\n";
cout<<"name: peter sykes\n";
cout<<"availability:"<<b<<"\n\n";
cout<<"book code:103\n";
cout<<"name: ncert maths\n";
cout<<"availability:"<<c<<"\n\n";
}


class ums
{

int regno,k,n,m;
public:
void library();
void attend();
void result();
void input()
{
cout<<"\t\t\tUNIVERSITY MANAGEMENT SYSTEM\n";
cout<<"START:\n";
cout<<"enter your registration no.";
cin>>regno;
}
void data();
};
void ums::data()
{
int j;
switch(regno)
{
case 11002356:
cout<<"name:Amit"<<"\n";
cout<<"section:K3001"<<"\n";
cout<<"enter [1] to go to library"<<"\n";
cout<<"enter [2] to see attendence"<<"\n";
cout<<"enter [3] to see result"<<"\n";
break;
case 11004567:
cout<<"name:Neeraj"<<"\n";
cout<<"section:K3001"<<"\n";
cout<<"enter [1] to go to library"<<"\n";
cout<<"enter [2] to see attendence"<<"\n";
cout<<"enter [3] to see result"<<"\n";
break;
case 11009096:
cout<<"name:Saurabh"<<"\n";
cout<<"section:K3001"<<"\n";
cout<<"enter [1] to go to library"<<"\n";
cout<<"enter [2] to see attendence"<<"\n";
cout<<"enter [3] to see result"<<"\n";
break;
default:
cout<<"regno. is incorrect\npress [9]";
}

}
void ums::library()
{
x:
cout<<"enter [1] to see available book"<<"\n";
cout<<"enter [2] to issue the book"<<"\n";
cout<<"enter [3] to return the book"<<"\n";
cout<<"press [9] to exit library\n"<<"\n";
cin>>k;
switch(k)
{
case 1:
lb.show();
cout<<"press [0] to go to menu of library\n";
cout<<"press [9] key to exit library\n";
cin>>m;
if(m==0)
goto x;
else
goto y;
case 2:
lb.issue();
cout<<"press [0] to go to  menu of library\n";
cout<<"press [9] key to exit library\n";
cin>>m;
if(m==0)
goto x;
else
goto y;

case 3:
lb.ret();
cout<<"press [0] to go to menu of library\n";
cout<<"press [9] key to exit library\n";
cin>>m;
if(m==0)
goto x;
else
goto y;
}
y:
}
void ums::attend()
{
int regno,phy,cmp,math,pass;
cout<<"enter your regno";
cin>>regno;
cout<<"enter password";
cin>>pass;
switch(regno)
{
case 11002356:
if(pass==3346)
{
phy=85,cmp=90,math=95;
cout<<"name:Amit\n";
cout<<"total attendence:"<<(phy+cmp+math)/3<<"%\n";
cout<<"maths:"<<math<<"%\n";
cout<<"computer:"<<cmp<<"%\n";
cout<<"physics:"<<phy<<"%\n";
}
else
cout<<"incorrect password\n";
break;
case 11004567:
if(pass==1234)
{
phy=95,cmp=90,math=87;
cout<<"name:Neeraj\n";
cout<<"total attendence:"<<(phy+cmp+math)/3<<"%\n";
cout<<"maths:"<<math<<"%\n";
cout<<"computer:"<<cmp<<"%\n";
cout<<"physics:"<<phy<<"%\n";
}
else
cout<<"incorrect password\n";
break;
case 11009096:
if(pass==1234)
{
phy=87,cmp=90,math=56;
cout<<"name:Saurabh\n";
cout<<"total attendence:"<<(phy+cmp+math)/3<<"%\n";
cout<<"maths:"<<math<<"%\n";
cout<<"computer:"<<cmp<<"%\n";
cout<<"physics:"<<phy<<"%\n";
}
else
cout<<"incorrect password\n";
break;
default:
cout<<"regno.incorrect\n";
}
}
void ums::result()
{
int l,o;
x:
cout<<"enter registration no.";
cin>>l;
switch(l)
{
case 11002356:
cout<<"name:Amit\n";
cout<<"subjects:"<<"grades\n";
cout<<"maths   :"<<"A\n";
cout<<"physics :"<<"A+\n";
cout<<"computer:"<<"B\n";
cout<<"press [0] to go to back\n";
cout<<"press [9] to exit result\n";
cin>>o;
if(o==0)
goto x;
else
goto y;
break;
case 11004567:
cout<<"name:Neeraj\n";
cout<<"subjects:"<<"grades\n";
cout<<"maths   :"<<"B\n";
cout<<"physics :"<<"A+\n";
cout<<"computer:"<<"C\n";
cout<<"press [0] to go to back\n";
cout<<"press [9] to exit result\n";
cin>>o;
if(o==0)
goto x;
else
goto y;
break;
case 11009096:
cout<<"name:Saurabh\n";
cout<<"subjects:"<<"grades\n";
cout<<"maths   :"<<"B\n";
cout<<"physics :"<<"C\n";
cout<<"computer:"<<"A+\n";
cout<<"press [0] to go to back\n";
cout<<"press [9] to exit result\n";
cin>>o;
if(o==0)
goto x;
else
goto y;
break;
default:
cout<<"regno. incorrect\n";
cout<<"press [0] to go to back\n";
cout<<"press [9] to exit  result\n";
cin>>o;
if(o==0)
goto x;
else
goto y;
}
y:
}


void main()
{
int n,k;
class ums u;
clrscr();
x:
u.input();
u.data();
cin>>n;
switch(n)
{
case 1:
u.library();
cout<<"enter [5] to goto start\n";
cout<<"press [9] to exit program\n";
cin>>k;
if(k==5)
goto x;
else
goto y;
case 2:
u.attend();
cout<<"enter [5] to goto start\n";
cout<<"press [9] to exit program\n";
cin>>k;
if(k==5)
goto x;
else
goto y;
case 3:
u.result();
cout<<"enter [5] to goto start\n";
cout<<"press [9] to exit program\n";
cin>>k;
if(k==5)
goto x;
goto y;
}
y:
getch();
}


To Check:-
  Registration no.-11002356 Password-3346
  Registration no.- 11004567  Password-1234                                       







Grading System In Linux


Grading System In Linux Programming by Shell script.

echo enter the name of student
read name
echo enter section
read section
echo enter marks of maths
read maths
echo enter marks of physics
read phy
echo enter marks of chemistry
read chem
if [ $maths -lt 35 ]
then
m=fail
elif [ $maths -lt 50 ]
then
m=C
elif [ $maths -lt 70 ]
then
m=B
elif [ $maths -lt 80 ]
then
m=A
elif [ $maths -lt 100 ]
then
m=A+
fi

if [ $phy -lt 35 ]
then
p=fail
elif [ $phy -lt 50 ]
then
p=C
elif [ $phy -lt 70 ]
then
p=B
elif [ $phy -lt 80 ]
then
p=A
elif [ $phy -le 100 ]
then
p=A+
fi

if [ $chem -lt 35 ]
then
c=fail
elif [ $chem -lt 50 ]
then
c=C
elif [ $chem -lt 70 ]
then
c=B
elif [ $chem -lt 80 ]
then
c=A
elif [ $chem -le 100 ]
then
c=A+
fi
echo name:$name section:$section
echo subject:      grades:
echo maths:        $m
echo physics:      $p
echo chemistry:    $c



Windows password recovery

Ophcrack is a free Windows password cracker based on rainbow tables. It is a very efficient implementation of rainbow tables done by the inventors of the method. It comes with a Graphical User Interface and runs on multiple platforms.
1-Download Ophcrack XP Live CD or Ophcrack Vista Live CD  depending which windows you want to crack.Ophcrack Vista Live CD will also work to crack Windows7 login password.
2-Download and run tazusb.exe.
3-Select Ophcrack iso image file and then pen drive.
4-Make pendrive bootable.
5-Reboot and change boot order to usb storage.
When ophcrack will open as an OS you can see the password of your Windows.
Ophcrack is Live USB so it is not going to affect Windows and it will crack Windows Login Password. 

Thursday 15 March 2012

Turboc++3 fullscreen in windows7 32 bit with graphics

 Use Turboc++3 in windows7 32 bit with graphics.
 Install tc++3. You can get here.
 Just follow the screenshots.To see fullscreen image click on image.
1- Click on left corner blue rectangle type image and go to properties.
2-Click on Font tab and choose Lusida Console & choose 28 size.
3-Choose Layout tab
   a-Choose screen buffer size Width:80, Hight:25.
   b-Window size Width:80, Hight:25.
   c-Window position Length: -4 ,Top: 4.
   d-Uncheck Let system position window.
                


                


















Note:It is not completely the fullscreen but it is modified to fullscreen.

 

Install Ubuntu inside Windows.

Install Ubuntu inside Windows.
1-Open Daemon Tools Lite. You can get here.
   Click to add ubuntu iso file from hard disk as in the snapshot.
2-Choose iso image file to add.
3-Click to add Virtual device as in screenshot.
4-A virtual device will be added down.
   Right click on iso image path shown below image catalog and choose mount then virtual    device and wait for few seconds.
5-Click on Run Wubi.exe.
6-Select Install inside windows. 
7-Select Installation drive, Installation size, Desktop Environment.
   Write Username: & Password:
  Then click on OK.
8-An  intial installation will start then select reboot.
Note:-When computer reboot Press ESC as it tells  and choose Normal Mode and wait for completion of installation.
                                                
                                                                                                                                                                                                                               




















                
                                                                 
                   





                          



Ubuntu Netbook Edition to Desktop Edition

Switch Ubuntu Netbook Edition to Ubuntu Desktop Edition or Safe Mode.
1-Go to  Applications in ubuntu netbook edition and choose Login Screen.
2-Unlock Login Screen by entering password.
3-Choose Ubuntu Desktop Edition or Safe Mode if you want to open in safe mode.
Note-When you will reboot your compter Ubuntu will be changed to Desktop Edition.
 
                 






















Emulated Turbo C++

Turbo C++ in Windows7 64-bit.
Emulated Turbo C++ can allow you to use turbo c++ in window7 64-bit.
You don't have to install dosbox mannualy ,it is already in the rar file.
You don't have to give command everytime.
The software is only going to work when you have external graphics card.
You can get here.