Showing posts with label c-plus plus program. Show all posts
Showing posts with label c-plus plus program. Show all posts

Wednesday 27 June 2012

c++ program to implement preemitive Priority based scheduling algorithm using function.

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {    cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";
        cin>>b;
        cout<<endl<<"enter prority time:";
        cin>>p;

c++ program to implement non-preemitive Shortest job first (SJF) scheduling algorithm using function

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{
    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {
       
        cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";

c++ program to implement non- preemitive Priority based scheduling algorithm using function.

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {    cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";
        cin>>b;
        cout<<endl<<"enter prority time:";
        cin>>p;

c++ program that accept string(chacter) input and convert it into a binary using function.

#include<iostream>
#include<string>
using namespace std;
void display(char c[])
    {
   
    for(int i=0;c[i]!='\0';i++)
    {

        int j=0;
        int temp[15];
                while(c[i]>0)
                {
                    temp[j]=c[i]%2;
                        c[i]=c[i]/2;
                        j=j+1;
                }
       

c++ program that write into a file and read from file using function.

#include<iostream>
#include<fstream>
using namespace std;

    void inputfile(char b)
        {
        ofstream myfile(b);
        char c[100];
        int a;
        cout<<"enter your number :";
        cin>>a;
        cout<<endl<<"enter your First Name:";
     

c++ program that read from file and write into file.

#include<iostream>
#include<fstream>
using namespace std;
    int main()
    {
        ofstream myfile("t1.txt");
        char c[100];
        int a;
        cout<<"enter your number :";
        cin>>a;
        cout<<endl<<"enter your First Name:";
        cin.getline(c,100);

Tuesday 26 June 2012

c++ program to dispaly flying birds.

#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <math.h>
#include <dos.h>
#include <stdlib.h>
#define ESC_KEY   0x1b

int tx=0,ty=0;
void getx(int &ox)
{
    if (ox==50)
    {
        tx=0;
        ox=ox+1;
    }
    else if (ox==getmaxx()-50)
    {
        tx=-1;
        ox=ox-1;
    }

c++ program to display moving car.

#include <iostream.h>
#include <graphics.h>
#include <dos.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#define ESC_KEY   0x1b

class wheel
{
int r,x,y,nx,ny,cx,cy;
float rd;
public:
wheel(int x2,int y2,int x1,int y1,int d)
{
cx=x2;
cy=y2;
x=x1;
y=y1;
rd=d*(3.14/180);
 generate();
}

c++ program to display walking man on a display.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
struct point
{
   float x,y;
} head;
typedef struct point p;
struct cnate
{    p p1;
     p p2;
}lhand,rhand,lleg,rleg,body;
typedef struct cnate c;
void draw(c temp)
{line(temp.p1.x,temp.p1.y,temp.p2.x,temp.p2.y);
  return;
}

Sunday 24 June 2012

c++ program to count total number of head movement using c- loop scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,lrem [5],t;
int rrem[5],prev=ub,current=0,qsize=n,lrsize=0,rrsize=0;
 

c++ program to count total number of head movement using loop scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;

c++ program to count total number of head movement using c-scan scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;

c++ program to count total number of head movement using scan scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;
cout<<"Enter your head:";
cin>>head;
int minindex;
int temp,len=0,i,j,lrem [5],t;
int rrem[5],prev=ub,current=0,qsize=n,lrsize=0,rrsize=0;
    for(i=0;i<n;i++)
    {

c++ program to count total number of head movement using Shortest seek job first(SSJF) scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
int n;
cout<<"enter your queue size:";
cin>>n;
int ub,lb=0;
cout<<"Enter your upper bound:";
cin>>ub;
int queue[3];
int head;

c++ program to count total number of head movement using first come first served(FCFS) scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
    int n;
    cout<<"enter your queue size:";
    cin>>n;
    int ub,lb=0;
    cout<<"Enter your upper bound:";
    cin>>ub;
    int queue[3];
    int head;
    cout<<"Enter your head:";
    cin>>head;

c++ program that accept string(chacters) input and convert it into a bianry and display it's binary.

#include<iostream>
#include<string>
using namespace std;
int main()
{
    char c[100];
    cout<<"Enter Your String: ";
    cin.getline(c,100);

    for(int i=0;c[i]!='\0';i++)
    {

c++ program to performed Page replacement using First Come First Served (FCFS) technique.

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<conio.h>

int main()
{
char c[12];
int size=3,fpoint=0,top=0;
int frame[3],stack[3];
cout<<"enter your string:";
cin>>c;
int i,j,val,flag=0,temp,fault=0;

c++ program to perform Page replacement using Least Recently Used (LRU) technique.

#include<iostream>
#include<fstream>
using namespace std;

int main()
{
char c[12];
int size=3,fpoint=0,top=0;
int frame[3],stack[3];
cout<<"enter your string:";
cin>>c;
int i,j,val,flag=0,temp,fault=0;
for(i=0;c[i]!='\0';i++)
{

c++ program of Round Robin scheduling algorithm.

#include<iostream.h>
#include<stdio.h>
#include<fstream.h>

int main()
{    int n=3;
    float total,wait[3]={0};
    float p[3],twaiting=0,waiting=0;
    int proc;
    int stack[3];
    float brust[3],arrival[3],sbrust,temp[3],top=3;
    for(int j=0;j<n;j++)
    {
   

Saturday 23 June 2012

c++ program of preemitive Shortest job first (SJF) scheduling algorithm.

#include<iostream.h>
#include<stdio.h>
int main()
{    int n=3;
    float total,wait[3]={0};
    float p[3],twaiting=0,waiting=0;
    int proc;
    int stack[3];
    float brust[3],arrival[3],sbrust,temp[3],top=3;
    for(int i=0;i<n;i++)
    {
        p[i]=i;
        stack[i]=i;
        cout<<"enter arival time :";
        cin>>arrival[i];
        cout<<endl<<"enter brust time:";
        cin>>brust[i];
        temp[i]=arrival[i];
        sbrust=brust[i]+sbrust;
    }