/*************Header File****************************/
#include<afxwin.h>
class CMyWnd : public CFrameWnd // My Window class
{
public:
CMyWnd();
afx_msg void OnTimer(UINT ID);
DECLARE_MESSAGE_MAP()
};
class CMyApp: public CWinApp // Application window class
{
public :
BOOL InitInstance(); // initinstace function with Boolian return type
};
/***************Source File**************************/
#include...
Friday, September 14, 2012
[C CODE] Process scheduling techniques
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<conio.h>
struct process
{
int pn,at,pt,tt,wt;
}p[20],tem[20],*q[20];
int i,j,k,choice,np,c=0;
int last=-1;
int processq[50],z;
char procg[50],z1;
void qinsert(struct process *a)
{
last=last+1;
q[last]=a;
}
void qdelete(void)
{
int l;
processq[z]=(*q[0]).pn;
z++;
for(l=0;l<last;l++)
q[l]=q[l+1];
...
[C CODE] Memory management techniques
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<alloc.h>
struct process
{
int size;
int hole;
}*p;
int *h,*tmp,hn,pn,i,j,k,rem,lh,sh;
//rem=0;
void input()
{
clrscr();
printf("Enter no of holes : ");
fflush(stdin);
scanf("%d",&hn);
h=(int *)malloc(sizeof(int)*hn);
for(i=0;i<hn;i++)
{
printf("size of hole %d : ",i+1);
fflush(stdin);
scanf("%d",&h[i]);
tmp[i]=h[i];
...
[shell script]Directory operations example
enter your choice
echo " 1. List of files & directories with permissions "
echo " 2. Create directory "
echo " 3. Remove directory "
echo " 4. Rename directory "
echo " 5. Go to directory "
echo " 6. Go out of directory "
read choice
case "$choice" in
1)ls -l;;
2) echo "Enter the name :"
read name
if [ -d $name ]
then
echo "directory is exist"
else
mkdir $name
echo "directory '$name' has been created"
...
DBMS using shell script
if [ ! -f dbms ]
then
touch dbms
fi
while [ 1 ]
do
echo " "
echo " "
echo " "
echo " The database management system operations : "
echo " 1.For inserting data into the file "
echo " 2.View all record of file "
echo " 3.For searching the data from the file "
echo " 4.For sorting the data of file "
echo " 5.For modifying the data into the file "
echo " 6.For Delete the record "
echo " 7.For Exit "
echo " Enter your choice : "
read choice
clear
case $choice in
1)echo " Enter...
shell script to find prime number
echo "Enter the limit : "
read no
i=2
while [ $i -le $no ]
do
j=1
flag=0
while [ $j -le $i ]
do
m=`expr $i % $j`
if [ $m -eq 0 ]
then
flag=`expr $flag + 1`
if [ $flag -gt 2 ]
then
break
fi
fi
j=`expr $j + 1`
done
if [ $flag -eq 2 ]
then
echo $i
fi
i=`expr $i + 1`
done
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre...
Head-Tail command example [shell script]
if [ $# -ne 2 ]
then
echo " invalid argument "
exit
fi
if [ ! -e $1 ]
then
echo "invalid file name "
exit
fi
echo " 1. head "
echo " 2. tail "
read ch
case "$ch" in
1)exec < $1
i=1
while [ $i -le $2 ]
do
read l
echo $l
i=`expr $i + 1`
done ;;
2)exec < $1
i=1
while read l
do
i=`expr $i + 1`
done
j=`expr $i - $2`
k=1
exec < $1
while [ $k -lt $j ]
do
read l
k=`expr $k + 1`
done
while read l
do
echo $l
done ;;
*) echo...
Fibonacci series using shell script
echo Enter the number
read n
i=0
b=1
a=0
echo " The fibonaci series is :"
while [ $i -lt $n ]
do
echo $b
b=`expr $a + $b`
a=`expr $b - $a`
i=`expr $i + 1`
done
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode...
date command shell script
if [ `date +%H` -lt 12 ]
then
echo "Good Morning"
elif [ `date +%H` -lt 16 ]
then
echo "Good After Noon"
else
echo "Good evening"
fi
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode...
File comparison using shell script
if [ $# -ne 2 ]
then
echo " invalid argument "
fi
if [ ! -f $1 ]
then
echo "file $1 is not exist "
fi
if [ ! -f $2 ]
then
echo " file $2 is not exist "
fi
if cmp $1 $2 >> \dev\null
then
echo " The files are same"
tac $1 > $2
rev $2 > $1
rm $2
echo The content of file $1 is :
cat $1
else
echo " The files are not identical "
fi
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color:...
Simple calculator using shell script
echo Enter The Two Numbers
read a
read b
echo enter operation
read op
ans1=`echo scale=2";" $a "$op" $b | bc`
echo the answer is $ans1
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color:...
Subscribe to:
Posts (Atom)