EmbLogic's Blog

about /proc

The Linux kernel has two primary functions: to control access to physical devices on the computer and to schedule when and how processes interact with these devices. The /proc/ directory — also called the proc file system — contains a hierarchy of special files which represent the current state of the kernel — allowing applications and users to peer into the kernel’s view of the system.

Within the /proc/ directory, one can find a wealth of information detailing the system hardware and any processes currently running. In addition, some of the files within the /proc/ directory tree can be manipulated by users and applications to communicate configuration changes to the kernel.It  also know as virtual file system.

Posted in Character Driver, Device Drivers | Leave a comment

implementation of queue using link list is completed

#include
#include
struct queue
{
int data;
struct queue *next;
}*start=NULL,*new_node,*current;
void qinsert();
void display();
void qdelete();
int front=0,rear=0;
int main()
{
int choice;
do
{
printf(“\n=========Main Menu========\n”);
printf(“0.Exit\n”);
printf(“1.Insert\n”);
printf(“2.Delete\n”);
printf(“3.Display\n”);
printf(“\nEnter you choice:”);
scanf(“%d”,&choice);
switch(choice)
{
case 0: exit;
break;
case 1: qinsert();
break;
case 2: qdelete();
break;
case 3: display();
break;
}

}while(choice);
}
void qinsert()
{
if(rear>5)
{
printf(“Queue full\n”);

}
else
{
new_node=(struct queue *)malloc(sizeof(struct queue));
printf(“Enter data:”);
scanf(“%d”,&new_node->data);
new_node->next=NULL;

if(!start)
{
start=new_node;
current=new_node;
rear++;
printf(“rear=%d\n”,rear);
}
else
{
current->next=new_node;
current=new_node;
rear++;
printf(“rear=%d\n”,rear);
}

}
}
void qdelete()
{
struct queue *temp;
if(rear==front)
{
printf(“Front=%d\nRear=%d\n”,front,rear);
printf(“Queue empty\n”);

}
else
{
temp=start->next;
start->next=NULL;
start=temp;
front++;
printf(“front is : %d\n”,front);

}

}
void display()
{
struct queue *check;
check=start;
while(check)
{
printf(“Queue:%d\n”,check->data);
check=check->next;
}
}

Posted in Data Structures with C | Leave a comment

implementation of queue using array is done.

RCS file: main.c,v
Working file: main.c
head:
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 0
description:
define function like:
insert
queue
delete
display
=============================================================================

RCS file: header.h,v
Working file: header.h
head:
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 0
description:
include header files.
declare an array of size 10
declare functions.
=============================================================================

Posted in Data Structures with C | Leave a comment

stack implemented successfully.

RCS file: main.c,v
Working file: main.c
head: 1.7
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 7; selected revisions: 7
description:
creat main menu
—————————-
revision 1.7
date: 2014/07/25 09:18:02; author: root; state: Exp; lines: +1 -6
stack
stack implementation completed successfully
—————————-
revision 1.6
date: 2014/07/25 09:14:22; author: root; state: Exp; lines: +8 -8
define traverse function
—————————-
revision 1.5
date: 2014/07/25 09:11:08; author: root; state: Exp; lines: +2 -2
define top element function
—————————-
revision 1.4
date: 2014/07/25 08:57:51; author: root; state: Exp; lines: +3 -3
define pop function
—————————-
revision 1.3
date: 2014/07/25 08:56:24; author: root; state: Exp; lines: +3 -3
define display function
—————————-
revision 1.2
date: 2014/07/25 08:53:20; author: root; state: Exp; lines: +4 -4
define push function
—————————-
revision 1.1
date: 2014/07/25 08:45:27; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
include header file
#include
#include
—————————-
revision 1.6
date: 2014/07/25 09:14:51; author: root; state: Exp; lines: +1 -1
declare traverse function
—————————-
revision 1.5
date: 2014/07/25 09:11:28; author: root; state: Exp; lines: +1 -0
declare top element function
—————————-
revision 1.4
date: 2014/07/25 08:58:00; author: root; state: Exp; lines: +1 -0
declare pop function.
—————————-
revision 1.3
date: 2014/07/25 08:56:36; author: root; state: Exp; lines: +1 -0
declare display function
—————————-
revision 1.2
date: 2014/07/25 08:54:30; author: root; state: Exp; lines: +2 -0
declare push function.
—————————-
revision 1.1
date: 2014/07/25 08:45:27; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C, Uncategorized | Leave a comment

Implemented Circular Queues with linked lists

#include<stdio.h>
#include<stdlib.h>
int flag=0;
struct node
{
int val;
struct node*next;
}*front=NULL,*rear=NULL,*start=NULL;
int count=0;
int get_choice(int *);
int create_node();
int enqueue();
int dequeue();
int display();
int main()
{
int choice=1;
while(choice)
{

printf(“\n+++++++++MENU+++++++++\n”);
printf(“1.CREATE NODE\n”);
printf(“2.INSERT\n”);
printf(“3.DELETE\n”);
printf(“4.DISPLAY\n”);
printf(“0.EXIT\n”);
printf(“enter your choice”);
scanf(“%d”,&choice);
get_choice(&choice);
}}
int get_choice(int *choice)
{
switch(*choice)
{
case 1:create_node();break;
case 2:enqueue();break;
case 3:dequeue();break;
case 4:display();break;
case 0:exit(0);
}}
int create_node()
{
if(flag==0)
{
printf(“queue created\n”);
flag++;
}
else if(flag>=1)
{
printf(“queue already created\n”);
}

}
int enqueue()
{
struct node*temp;
temp=(struct node*)malloc(10*sizeof(struct node*));

if(flag==0)
{
printf(“create a queue first\n”);
return 0;
}
else if(flag==1)
{
printf(“enter the values\n”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
start=rear=temp;
}
if(flag>1)
{
printf(“enter the values!\n”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
rear->next=temp;
rear=rear->next;

}
if(flag>5)
{

printf(“queue is full\n”);
return 0;
}
flag++;
display();
}
int dequeue()
{
struct node*temp,*temp1;
{
if(flag==0)
printf(“create a queue first\n”);

else if(flag==1)
{
printf(“queue is empty\n`”);

}
if(!front )
{
temp=start;
front=start->next;
printf(“%d is popped\n”,temp->val);
free(temp);

}
else if(front)
{
temp=front;
front=front->next;
printf(“%d is popped\n”,temp->val);
free(temp);
printf(“\n%d”,flag);
flag–;
}

display();

}}
int display()
{
struct node*temp;

if(flag==0)
{
printf(“nothing to display\n”);
}
else if(flag>=1)
{
if(!front)
{
temp=start;
}
else
{
temp=front;
}
while(temp)
{
printf(” %d–”,temp->val);
temp = temp->next;
}
}}

Posted in Uncategorized | Leave a comment

Implemented Queues with linked lists

#include<stdio.h>
#include<stdlib.h>
struct node
{
int val;
struct node*next;
}*front,*rear,*start=NULL;
int flag=0;
int get_choice(int*);
int create_node();
int enqueue();
int dequeue();
int display();
int main()
{
int choice=1;

while (choice)
{
printf(“+++++++++++++++++++MENU++++++++++++++++++++++\n                “);
printf(”                1.CREATE NODE                \n                “);
printf(”                2.ENQUEUE                    \n                “);
printf(”                3.DEQUEUE                    \n                “);
printf(”                4.DISPLAY                    \n                “);
printf(”                0.EXIT                       \n                “);
printf(“enter your choice\n”);
scanf(“%d”,&choice);
get_choice(&choice);
}}
int get_choice(int*choice)
{
switch(*choice)
{
case 1:create_node();break;
case 2:enqueue();break;
case 3:dequeue();break;
case 4:display();break;
case 0:exit(0);break;
}}
int create_node()
{
if(flag==0)
{
front=NULL;
rear=NULL;
printf(“queue created successfully”);
flag++;
}
else if(flag==1)
{
printf(“queue already created”);
}
}
int enqueue()
{
struct node*temp;
int i;
temp=(struct node*)malloc(sizeof(struct node));

if(flag==0)
{
printf(“queue not created\n”);
return 0;
}
else if(flag>5)
{
printf(“queue is full\n”);
return 0;
}
if(flag == 1)
{

printf(“enter the value to insert\n”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
start=rear=temp;
flag++;
}
else if(flag>1 && flag!=1)
{
printf(“enter value”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
rear->next=temp;
rear=rear->next;
flag++;
}

printf(“element inserted %d\n”,flag);

display();

}
int dequeue()
{
struct node*temp;
i:    if(flag == 0 )
{
printf(“queue empty\n”);
return 0;
}
if(front == rear)
{
goto o;
}
if(!front)
{
front=start->next;
printf(“%d is dequed\n”,start->val);

}
else if(front)
{
temp=front;
front=front->next;
printf(“%d is dequed\n”,temp->val);
}
else if(front == rear && front->next==NULL)
{

o:    printf(“%d is dequed\n”,front->val);
printf(“queue empty\n”);
front->next=NULL;
rear=front=start->next=NULL;
flag =0;
goto i;
}

display();

}
int display()
{
struct node*temp;
if(flag==0)
{    printf(“create a queue first\n”);
return 0;
}
if(!front)
temp = start;
else
temp = front;
while(temp!=NULL)
{
printf(“<-%d”,(temp)->val);
temp=temp->next;

}
printf(“\n”);

}

Posted in Uncategorized | Leave a comment

what is the error in following code?

Point out the error in the following program.
#include
#include
void varfun(int n, …);

int main()
{
varfun(3, 7, -11.2, 0.66);
return 0;
}
void varfun(int n, …)
{
float *ptr;
int num;
va_start(ptr, n);
num = va_arg(ptr, int);
printf(“%d”, num);
}

Posted in Uncategorized | Leave a comment

is there any structure declaration in header file ?

A header file contains macros, structure declaration and function prototypes.
A. True
B.false

Posted in Uncategorized | Leave a comment

what will answer of this qn.

In which order do the following gets evaluated
1. Relational
2. Arithmetic
3. Logical
4. Assignment

Posted in Uncategorized | Leave a comment

linklist

RCS file: ./linklist1.c,v
Working file: ./linklist1.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
make a struct for linklist and defined three pointers start,prev,end .
data store more than 10 bytes in single node.
create multiple node.
—————————-
revision 1.4 locked by: root;
date: 2014/07/24 18:30:09; author: root; state: Exp; lines: +31 -0
dispay all node , insert node at key position where you want.
—————————-
revision 1.3
date: 2014/07/21 16:57:35; author: root; state: Exp; lines: +130 -18
===============================ENTER 1 : FOR CREATE NODE===============================\n”);
139 printf(” ===============================ENTER 2 : FOR CREATE DATA===============================\n”);
140 printf(” ===============================ENTER 3 : FOR GIVE DATA TO NODE=========================\n”);
141 printf(” ===============================ENTER 4 : FOR CREATE NEW NODE===========================\n”);
142 printf(” ===============================ENTER 5 : FOR DISPLAY NODES=============================\n”);
143 printf(” ===============================ENTER 6 : FOR DELETE NODE FROM LAST=====================\n”);
144 printf(” ===============================ENTER 7 : FOR DELETE NODE FROM BEGNING==================\n”);
145 printf(” ===============================ENTER 8 : FOR INSERT NODE FROM BEGNING==================\n”);
—————————-
revision 1.2
date: 2014/07/15 11:15:21; author: root; state: Exp; lines: +33 -10
create linklist in loop and delete in while according to choice.
—————————-
revision 1.1
date: 2014/07/15 04:51:16; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

synchronization techniques

The various synchronization techniques at kernel level are-
Semaphore
Completions
Spinlock

in semaphore we use system calls- up and down
before entering into critical section the integer semaphore value is decremented by using down and it is incremented using call up after critical section.

Completion is another kernel level synchronization technique that has advantage over semaphore that it is light weight operation. It does not require any weight queue…….the calls used in completion are- wait_for_copmletion and complete and also complete_all.

Spinlock is used in process that cannot sleep such as interrupt handler. In spinlock execution in critical section is atomic,non_interruptable.The calls used in spinlock are spin_lock and spin_unlock.

Posted in Character Driver | Leave a comment

data Decompresion Done !!!!!!!!!

RCS file: file.c,v
Working file: file.c
head: 1.18
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 18;    selected revisions: 18
description:
This is main Program file for the Multiple Data Compression(MDC)
in which i use file_open function for read the file
and master_array function are used for to create master array
—————————-
revision 1.18
date: 2014/07/21 00:04:01;  author: root;  state: Exp;  lines: +7 -7
decompression function added .
—————————-
revision 1.17
date: 2014/07/10 02:19:20;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
—————————-
revision 1.16
date: 2014/07/10 02:02:35;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.15
date: 2014/07/10 01:58:06;  author: root;  state: Exp;  lines: +2 -1
Compression function are calling and some error solving
—————————-
revision 1.14
date: 2014/07/10 01:16:07;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.13
date: 2014/07/10 01:08:17;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.12
date: 2014/07/10 00:45:16;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.11
date: 2014/07/10 00:24:37;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.10
date: 2014/07/10 00:00:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2014/07/09 23:30:37;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.8
date: 2014/07/09 23:20:15;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2014/07/09 23:19:17;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.6
date: 2014/07/09 23:18:30;  author: root;  state: Exp;  lines: +1 -1
error solved
—————————-
revision 1.5
date: 2014/07/09 23:12:49;  author: root;  state: Exp;  lines: +3 -5
calling array length finding function
—————————-
revision 1.4
date: 2014/07/09 22:48:21;  author: root;  state: Exp;  lines: +0 -43
Seprate Function from the main programe file to other function file
—————————-
revision 1.3
date: 2014/07/09 22:12:30;  author: root;  state: Exp;  lines: +1 -1
error are removed by using adding ‘;’
—————————-
revision 1.2
date: 2014/07/09 22:11:41;  author: root;  state: Exp;  lines: +1 -1
some changes are done
—————————-
revision 1.1
date: 2014/07/09 22:00:46;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: functionn.c,v
Working file: functionn.c
head: 1.51
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 51;    selected revisions: 51
description:
Function file in which we include all the project programme function
—————————-
revision 1.51
date: 2014/07/21 00:42:05;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.50
date: 2014/07/21 00:31:31;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.49
date: 2014/07/21 00:16:19;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.48
date: 2014/07/21 00:15:35;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.47
date: 2014/07/21 00:12:51;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.46
date: 2014/07/21 00:11:22;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.45
date: 2014/07/21 00:09:50;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.44
date: 2014/07/21 00:08:20;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.43
date: 2014/07/21 00:07:19;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.42
date: 2014/07/21 00:06:28;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.41
date: 2014/07/21 00:04:32;  author: root;  state: Exp;  lines: +17 -0
*** empty log message ***
—————————-
revision 1.40
date: 2014/07/20 23:03:08;  author: root;  state: Exp;  lines: +4 -7
*** empty log message ***
—————————-
revision 1.39
date: 2014/07/20 22:53:28;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
—————————-
revision 1.38
date: 2014/07/20 22:51:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.37
date: 2014/07/10 03:14:08;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.36
date: 2014/07/10 03:06:00;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.35
date: 2014/07/10 03:01:26;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.34
date: 2014/07/10 02:55:10;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.33
date: 2014/07/10 02:53:36;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.32
date: 2014/07/10 02:48:56;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.31
date: 2014/07/10 02:47:30;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.30
date: 2014/07/10 02:44:55;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.29
date: 2014/07/10 02:44:09;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.28
date: 2014/07/10 02:43:01;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.27
date: 2014/07/10 02:37:53;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.26
date: 2014/07/10 02:25:40;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.25
date: 2014/07/10 02:22:00;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.24
date: 2014/07/10 02:20:22;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.23
date: 2014/07/10 02:16:27;  author: root;  state: Exp;  lines: +4 -2
*** empty log message ***
—————————-
revision 1.22
date: 2014/07/10 02:10:27;  author: root;  state: Exp;  lines: +0 -1
*** empty log message ***
—————————-
revision 1.21
date: 2014/07/10 02:09:35;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.20
date: 2014/07/10 02:04:53;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2014/07/10 02:02:37;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.18
date: 2014/07/10 01:59:19;  author: root;  state: Exp;  lines: +37 -5
function are added like compression , find_loc
—————————-
revision 1.17
date: 2014/07/10 01:17:45;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.16
date: 2014/07/10 01:17:03;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.15
date: 2014/07/10 01:16:10;  author: root;  state: Exp;  lines: +6 -6
*** empty log message ***
—————————-
revision 1.14
date: 2014/07/10 01:08:20;  author: root;  state: Exp;  lines: +4 -4
*** empty log message ***
—————————-
revision 1.13
date: 2014/07/10 00:59:54;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.12
date: 2014/07/10 00:58:40;  author: root;  state: Exp;  lines: +3 -1
*** empty log message ***
—————————-
revision 1.11
date: 2014/07/10 00:47:46;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.10
date: 2014/07/10 00:34:36;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2014/07/10 00:24:38;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.8
date: 2014/07/10 00:00:46;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2014/07/09 23:58:19;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.6
date: 2014/07/09 23:44:07;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.5
date: 2014/07/09 23:42:38;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2014/07/09 23:41:17;  author: root;  state: Exp;  lines: +3 -1
*** empty log message ***
—————————-
revision 1.3
date: 2014/07/09 23:33:39;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2014/07/09 23:14:59;  author: root;  state: Exp;  lines: +12 -1
writing length_code function
—————————-
revision 1.1
date: 2014/07/09 22:49:49;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.9
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 9;    selected revisions: 9
description:
it is the source of the Header File In which we include
stdio.h
stdlib.h
fcntl.h
—————————-
revision 1.9
date: 2014/07/21 00:04:22;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.8
date: 2014/07/10 02:04:52;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2014/07/10 01:58:53;  author: root;  state: Exp;  lines: +2 -0
function declereton are added
—————————-
revision 1.6
date: 2014/07/10 01:16:09;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.5
date: 2014/07/10 01:08:18;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2014/07/09 23:22:55;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2014/07/09 23:14:13;  author: root;  state: Exp;  lines: +1 -1
include array length_code decleration
—————————-
revision 1.2
date: 2014/07/09 22:49:06;  author: root;  state: Exp;  lines: +9 -0
include header file math.h and string.h
and function decleretion
—————————-
revision 1.1
date: 2014/07/09 22:07:17;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Circular queue using Link list

MAIN..

#include”header.h”

int main()
{
int choice,n=0;
struct node *start;
start=NULL;
printf(“\n ENTER THE SIZE OF CIRCULAR QUEUE\n”);
scanf(“%d”,&n);
while(1)
{
choice=getchoice();
operation(choice,&start,n);

}
return 0;
}

FUNCTION DEFINITIONS..

#include”header.h”
struct node *front,*rear=NULL;
struct node *temp =NULL;
int count=-1,flag=0,num=0;

int getchoice()
{
int choice;
printf(“\n1. CREATE “);
printf(“\n2. ENQUEUE”);
printf(“\n3. DEQUEUE “);
printf(“\n4. DISPLAY”);
printf(“\n0. EXIT\n”);
printf(“\n\n Enter your choice\n”);
scanf(” %d”,&choice);
return choice;
}
int operation(int choice ,struct node **start,int n)
{
switch(choice)
{
case 1 :  create(start);
break;
case 2 :  enqueue(start,n,choice);
break;
case 3 :  dequeue(start);
break;
case 4 :  display(start);
break;
case 0 : exit(0);
break;
default : printf(“\ninvalid operation”);
}
}

int create(struct node **start)
{
if(flag)
{
printf(“\n THE CIRCULAR QUEUE IS ALREADY CREATED!!”);
return -1;
}
if(!flag)
{
(*start)=NULL;
printf(“\n THE QUEUE CREATED SUCESSFULLY”);
flag=1;
}
}
int enqueue(struct node **start,int n,int choice)
{
if(flag)
{
if(num==0)
{
(*start)=(struct node *)malloc(sizeof(struct node));
printf(“\n ENTER THE VERY FIRST ELEMENT\n”);
scanf(“%d”,&((*start)->info));
(*start)->next=NULL;
rear=(*start);
front=(*start);
count++;
num=1;
return 0;
}
if(count==(n-1))
{
printf(“\n THE QUEUE IS FULL\n”);
return 0;
}
else
{
rear->next=malloc(sizeof(struct node));
rear=rear->next;
printf(“\n ENTER THE INFO : \n”);
scanf(“%d”,&(rear->info));
count++;
}
}
}

int dequeue(struct node **start)
{
if(flag)
{
if(front==rear)
{
if(count==(-1))
{
printf(“\n THE QUEUE IS EMPTY”);
return 0;
}
printf(“\n THE ELEMENT REMOVED IS %d”,front->info);
front=NULL;
rear=NULL;
num=0;
//    flag=0;
count–;

}

else if(front!=rear)
{
printf(“\n THE ELEMENT REMOVED IS %d”,front->info);
front = front->next;
count–;
}
}
if(!flag)
printf(“\nTHE QUEUE IS EMPTY….!!”);
}
int display(struct node **start)
{
if(flag)
{
if(front==NULL)
{
printf(“\n THE QUEUE IS EMPTY”);
return 0;
}
temp=front;
printf(“THE ELEMENTS ARE”);
while(temp!=rear)
{
printf(“–>  %d”,temp->info);
temp = temp->next;
}
if(temp==rear)
printf(“–> %d”,temp->info);
return 0;
}
if(!flag)
{    printf(“\n THE QUEUE IS EMPTY…!! NOTHING TO SHOW”);
}
}

Posted in Uncategorized | Leave a comment

Implementation of Circular Queue using linked list.

HEADER

***************************************************************

#include<stdio.h>
#include<stdlib.h>
struct cq
{
int info;
struct cq *next;
};
int getchoice();
int operation(int, struct cq **, struct cq **, struct cq **);
int enqueue( struct cq **, struct cq **, struct cq **);
int display( struct cq **, struct cq **, struct cq **);
int dequeue( struct cq **, struct cq **, struct cq **);

 

 

MAIN

***************************************************************

#include”header.h”
int main()
{
struct cq *front = NULL , *rear = NULL, *start = NULL;
int choice;
while(1)
{
choice = getchoice();
operation(choice,&front,&rear,&start);
}
}

 

DEFINITIONS

***********************************************************************

#include”header.h”
int flag = 0,count = -1;
int getchoice()
{
int choice;
printf(”                   1.create\n”);
printf(”                   2.enqueue\n”);
printf(”                   3.dequeue\n”);
printf(”                   4.display\n”);
printf(”                   5.exit\n”);
printf(”                Enter your choice\n”);
scanf(“%d”,&choice);
return choice;
}
int operation(int choice, struct cq **front, struct cq **rear,struct cq **start)
{
int i,k;
switch(choice)
{
case 1:    if(flag == 0)
{
printf(“successfully created!!\n”);
flag = 1;
}
else
printf(“already created\n”);
break;
case 2:{
printf(“How many elments you want to enqueue?\n”);
scanf(“%d”,&k);
if(k > (10-(count+1)))
{
printf(“no sufficient space!! you can enter %d more elements\n”,10-(count+1));
break;
}
for(i = 0; i < k; i++)
{
enqueue(front,rear,start);
}
printf(“%d elements entered!!\n”,k);break;
}
case 3:{
printf(“How many elments you want to dequeue?\n”);
scanf(“%d”,&k);
if(k > (count+1))
{
printf(” you can dequeue %d elements only\n”,(count+1));
break;
}
for(i = 0; i < k; i++)
{
dequeue(front,rear,start);
}
printf(“%d elements dequeued!!\n”,k);break;
}
case 4:display(front,rear,start);break;
case 5:exit(0);
default:printf(“invalid choice\n”);
}
}
int dequeue(struct cq **front, struct cq **rear,struct cq **start)
{
struct cq *temp;
if(flag == 0)
{
printf(“c queue not created!!\n”);
return -1;;
}
if(count == -1)
{
printf(“c queue is empty(underflow)\n”);
return 0;
}
if(!(*front))
{
temp = *start;
*front = (*start)->next;
printf(“%d is dequeued\n”,temp->info);
free(temp);
*start = NULL;
count–;
}
else if(count == 0)
{
printf(“%d is dequeued\n”,(*front)->info);
*front = *rear = NULL;
count–;
}

else if(count > 0)
{
temp = *front;
*front = (*front)->next;
printf(“%d is dequeued\n”,temp->info);
count–;
}
//    printf(“count: %d\n”,count);
display(front,rear,start);

}
int enqueue(struct cq **front, struct cq **rear,struct cq **start)
{
struct cq *temp;
if(flag == 0)
{
printf(“queue not created!!\n”);
return -1;;
}
if(count >= 9)
{
printf(“c Queue is full!\n”);
return 0;
}
if(!(*rear))
{
*rear = malloc(sizeof(struct cq));
printf(“Enter the %d element\n”,count+1);
scanf(“%d”,&((*rear)->info));
(*rear)->next = NULL;
*start = *rear;
}
else if(rear)
{
temp = malloc(sizeof(struct cq));
(*rear)->next = temp;
*rear = (*rear)->next;
printf(“Enter the %d element\n”,count+1);
scanf(“%d”,&(temp->info));
(temp)->next = NULL;
}
count++;
//    printf(“count: %d\n”,count);
display(front,rear,start);
}
int display(struct cq **front, struct cq **rear,struct cq **start)
{
struct cq *temp;
if(flag == 0)
{
printf(“queue not created!!\n”);
return -1;;
}
if(!(*rear) && !(*front))
printf(“c queue is empty\n”);
if(!(*front) && *rear)
temp = *start;
else
temp = *front;
while(temp)
{
printf(“<-%d”,temp->info);
temp = temp->next;
}
printf(“\n”);
}

Posted in Uncategorized | Leave a comment

MDC completed (upto 2 bit,4 bit compression/decompression)

RCS file: ./mdc_using_functions.c,v
Working file: ./mdc_using_functions.c
head: 1.26
branch:
locks: strict
root: 1.26
access list:
symbolic names:
keyword substitution: kv
total revisions: 26;    selected revisions: 26
description:
reading characters from the file & adding to the master array
—————————-
revision 1.26    locked by: root;
date: 2014/07/23 12:06:33;  author: root;  state: Exp;  lines: +60 -1
gave defination for function uncompress_2().
compression,decompression for 2,4 bit completed.
—————————-
revision 1.25
date: 2014/07/23 11:47:19;  author: root;  state: Exp;  lines: +10 -2
implemented condition for writing 3 left characters to compressed file in compress_2().
—————————-
revision 1.24
date: 2014/07/23 10:56:01;  author: root;  state: Exp;  lines: +7 -2
implemented condition for writing 2 left char to compressed file in compress_2().
—————————-
revision 1.23
date: 2014/07/23 10:34:21;  author: root;  state: Exp;  lines: +8 -3
gave condition for writing single left character to compressed file in 2 bit.
—————————-
revision 1.22
date: 2014/07/23 10:18:50;  author: root;  state: Exp;  lines: +1 -1
in compress_2,changes char to unsigned char.
—————————-
revision 1.21
date: 2014/07/23 10:15:51;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
—————————-
revision 1.20
date: 2014/07/23 10:12:48;  author: root;  state: Exp;  lines: +1 -1
changed code length condition (ndc<4) for 2 bit for writing less than 3 character to compressed file.
—————————-
revision 1.19
date: 2014/07/23 09:48:18;  author: root;  state: Exp;  lines: +3 -3
changed code lenght for 2 bit and 4 bit.
—————————-
revision 1.18
date: 2014/07/23 09:40:46;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.17
date: 2014/07/23 09:33:15;  author: root;  state: Exp;  lines: +1 -1
changed condition for code length for 2 bit.
—————————-
revision 1.16
date: 2014/07/23 09:30:02;  author: root;  state: Exp;  lines: +30 -6
implemented defination for function compress_2().
—————————-
revision 1.15
date: 2014/07/23 08:36:05;  author: root;  state: Exp;  lines: +25 -2
gave defination for function find_location().
—————————-
revision 1.14
date: 2014/07/23 08:06:07;  author: root;  state: Exp;  lines: +0 -1
\.
—————————-
revision 1.13
date: 2014/07/23 08:03:18;  author: root;  state: Exp;  lines: +1 -3
removed undesired printf test statements.
—————————-
revision 1.12
date: 2014/07/23 07:56:08;  author: root;  state: Exp;  lines: +18 -14
imlemented condition for writing single character to compressed file with code length 4 bit.
—————————-
revision 1.11
date: 2014/07/21 13:51:24;  author: root;  state: Exp;  lines: +0 -1
\gave protorype for function uncompress_4().
implemented uncompress_4().
—————————-
revision 1.10
date: 2014/07/21 13:50:10;  author: root;  state: Exp;  lines: +0 -1
declared function uncompress.
—————————-
revision 1.9
date: 2014/07/19 09:32:36;  author: root;  state: Exp;  lines: +96 -20
*** empty log message ***
—————————-
revision 1.8
date: 2014/07/04 06:31:24;  author: root;  state: Exp;  lines: +1 -1
changed name of compressed file
—————————-
revision 1.7
date: 2014/07/04 06:14:17;  author: root;  state: Exp;  lines: +76 -41
compressed a file using masterarray as key.
implemented write_file inside compress4 instead of new function
—————————-
revision 1.6
date: 2014/07/02 15:37:45;  author: root;  state: Exp;  lines: +87 -5
gave defination for function compression
gave defination for function compress4
compressed masterarray to a file with code length- 4 bit
—————————-
revision 1.5
date: 2014/06/30 13:29:36;  author: root;  state: Exp;  lines: +75 -64
declared while inside function create_master_array
—————————-
revision 1.4
date: 2014/06/30 10:48:53;  author: root;  state: Exp;  lines: +21 -3
gave defination for function code_length_conv for finding code length
—————————-
revision 1.3
date: 2014/06/30 09:44:43;  author: root;  state: Exp;  lines: +4 -1
finding no of distnict in master_array
—————————-
revision 1.2
date: 2014/06/30 09:37:46;  author: root;  state: Exp;  lines: +15 -3
gave the defination for function data_compress for adding distnict char to master array
—————————-
revision 1.1
date: 2014/06/30 07:17:55;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment