EmbLogic's Blog

IPC (Inter Processing Communication)

This project is based on the communication between the two processes where the first process is the client and the second process is the processing client.

The client first sends the data request to the server which then transfer this data to the processing clients through a pipe which then process this data and send the corresponding result to the server.

After receiving the data from the processing client the server send the result back to the client.

Here, in this program three clients sends the data request  one by one and the wait for the server to send the result.

Click the link below to open the source code

source code

Posted in Project 03: Client Server Communication using Linux and IPC | Tagged | Leave a comment

Stack (create,push, pop & display) RCS logfile

RCS file: createstack.c,v
Working file: createstack.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func will create a new stack of size entered by the user
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:01:23;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: displaystack.c,v
Working file: displaystack.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func will display all the elements of the stack
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:01:57;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: functionpointer.c,v
Working file: functionpointer.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func defines all the functions pointers
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:02:26;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this is the main func which takes operation choice from the user and pass it to operations()
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:02:49;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func displays the main menu
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:03:41;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: operations.c,v
Working file: operations.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func calls different func’s depending on user’s choice
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:03:58;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: popstack.c,v
Working file: popstack.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func pops an element at the top of the stack
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:04:32;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: pushstack.c,v
Working file: pushstack.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func push/inserts an element at the top of the stack
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:05:00;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file includes all the header files used in the project
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:05:24;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: prototypes.h,v
Working file: prototypes.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file declares all the functions used in the project
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:05:53;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: struct.h,v
Working file: struct.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file contains declaration of structure
—————————-
revision 1.1    locked by: root;
date: 2017/04/08 09:06:25;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Tagged | Leave a comment

Linklist insertion, deletion, traversing, sorting (bubble & insertion sort) logfile

RCS file: bubblesort.c,v
Working file: bubblesort.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func sort the elements in the lilnlist using bubble sort method
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 06:04:20;  author: root;  state: Exp;  lines: +6 -5
changed sorting logic
—————————-
revision 1.1
date: 2017/04/05 05:01:03;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: createlinklist.c,v
Working file: createlinklist.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func creates a new Linklist having one node
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:01:47;  author: root;  state: Exp;  lines: +1 -2
updated the arguments passed to this func
—————————-
revision 1.1
date: 2017/03/30 14:52:59;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: createnode.c,v
Working file: createnode.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func creates a new node and returns a pointer to its starting address
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:03:22;  author: root;  state: Exp;  lines: +3 -0
updated the arguments passed to this func
—————————-
revision 1.1
date: 2017/03/30 14:54:03;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletebeginning.c,v
Working file: deletebeginning.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func deletes the node at beggining
beginning
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:03:33;  author: root;  state: Exp;  lines: +7 -4
updated the arguments passed to this func
now only strt is passed
—————————-
revision 1.1
date: 2017/03/30 14:55:04;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deleteend.c,v
Working file: deleteend.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func deletes the last node in the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:03:58;  author: root;  state: Exp;  lines: +13 -12
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 14:55:49;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletekey.c,v
Working file: deletekey.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func deletes a specific node containing the key element typed by user
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:04:22;  author: root;  state: Exp;  lines: +16 -49
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 14:56:22;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletemenu.c,v
Working file: deletemenu.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func shows different node deleting options
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:04:29;  author: root;  state: Exp;  lines: +1 -1
changed the options to display
—————————-
revision 1.1
date: 2017/03/30 14:57:13;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletenode.c,v
Working file: deletenode.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this func calls the different node deleting functions as per the user’s choice
—————————-
revision 1.3    locked by: root;
date: 2017/04/05 18:44:43;  author: root;  state: Exp;  lines: +0 -8
no change
—————————-
revision 1.2
date: 2017/04/05 05:05:46;  author: root;  state: Exp;  lines: +9 -23
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 14:57:49;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: deletenth.c,v
Working file: deletenth.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func deletes a node at nth location
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:05:54;  author: root;  state: Exp;  lines: +46 -33
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 14:59:11;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: functionpointer.c,v
Working file: functionpointer.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
this func defines the pointer to the functions used in the application
—————————-
revision 1.4    locked by: root;
date: 2017/04/05 18:42:53;  author: root;  state: Exp;  lines: +1 -0
added shiftnode() pointer
—————————-
revision 1.3
date: 2017/04/05 17:06:42;  author: root;  state: Exp;  lines: +1 -0
added insertionsort func pointer and shiftnode func pointer
—————————-
revision 1.2
date: 2017/04/05 05:06:16;  author: root;  state: Exp;  lines: +8 -0
added new function pointers
—————————-
revision 1.1
date: 2017/03/30 14:59:45;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertbeginning.c,v
Working file: insertbeginning.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func inserts a node at the beginning of the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:06:46;  author: root;  state: Exp;  lines: +6 -7
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 15:00:23;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertend.c,v
Working file: insertend.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func inserts a new node at the at the end of the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:06:58;  author: root;  state: Exp;  lines: +6 -5
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 15:00:48;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertionsort.c,v
Working file: insertionsort.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.4    locked by: root;
date: 2017/04/05 18:43:09;  author: root;  state: Exp;  lines: +8 -6
added comments
—————————-
revision 1.3
date: 2017/04/05 17:10:40;  author: root;  state: Exp;  lines: +1 -1
defined variable “div”
—————————-
revision 1.2
date: 2017/04/05 17:07:20;  author: root;  state: Exp;  lines: +29 -15
this func will sort the elements of the linklist using insertion sort technique
—————————-
revision 1.1
date: 2017/04/05 05:07:02;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertkey.c,v
Working file: insertkey.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func inserts a new node at the nth location
correction*-this func inserts a new node at after a key element enterd by user
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:07:07;  author: root;  state: Exp;  lines: +12 -17
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 15:01:33;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertmenu.c,v
Working file: insertmenu.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this is the func to display differnt node insertion options to the user
—————————-
revision 1.1    locked by: root;
date: 2017/03/30 15:02:51;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertnode.c,v
Working file: insertnode.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func calls different node inserting functions as per the user’s choice
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:07:34;  author: root;  state: Exp;  lines: +13 -27
updated the arguments passed to this func
—————————-
revision 1.1
date: 2017/03/30 15:04:02;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: insertnth.c,v
Working file: insertnth.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func inserts a new node at nth location in the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:07:42;  author: root;  state: Exp;  lines: +51 -38
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 15:04:39;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this is the main func which calls the operations()
—————————-
revision 1.3    locked by: root;
date: 2017/04/05 18:43:30;  author: root;  state: Exp;  lines: +2 -2
added comments
—————————-
revision 1.2
date: 2017/04/05 05:08:01;  author: root;  state: Exp;  lines: +14 -2
called the mainmenu() form main
previously it was called in the operations()
—————————-
revision 1.1
date: 2017/03/30 15:05:08;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this is the mainmenu which displays at the beginning of the program
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:08:47;  author: root;  state: Exp;  lines: +1 -1
updated the main menu options
—————————-
revision 1.1
date: 2017/03/30 15:05:38;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: operations.c,v
Working file: operations.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this function calls the functions for differnt operations to be performed on the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:09:17;  author: root;  state: Exp;  lines: +32 -45
removed statement for calling mainmenu()
now called in the main() only
—————————-
revision 1.1
date: 2017/03/30 15:06:14;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: shiftnode.c,v
Working file: shiftnode.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func inserts the node to a desired location while using insertion sort
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 18:43:37;  author: root;  state: Exp;  lines: +3 -6
logical error
—————————-
revision 1.1
date: 2017/04/05 17:07:59;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: sortmenu.c,v
Working file: sortmenu.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func shows the different sorting techniques options
to sort the elements in the linklist
—————————-
revision 1.1    locked by: root;
date: 2017/04/05 05:10:16;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: sortnode.c,v
Working file: sortnode.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func calls the different sorting functions as per the user’s choice
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 17:09:04;  author: root;  state: Exp;  lines: +1 -1
added insertionnode() call
—————————-
revision 1.1
date: 2017/04/05 05:11:11;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: swapnode.c,v
Working file: swapnode.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this func swap two nodes
—————————-
revision 1.1    locked by: root;
date: 2017/04/05 05:12:03;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: traversenode.c,v
Working file: traversenode.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func is responsible for displaying all the elements in the Linklist
—————————-
revision 1.2    locked by: root;
date: 2017/04/05 05:13:15;  author: root;  state: Exp;  lines: +12 -9
updated the arguments passed to this func
>> now only strt is pas
—————————-
revision 1.1
date: 2017/03/30 15:07:03;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file includes the header files from the system library
—————————-
revision 1.1    locked by: root;
date: 2017/03/30 15:07:47;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: prototypes.h,v
Working file: prototypes.h
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this file contains the declarations of the functions used in the program
—————————-
revision 1.3    locked by: root;
date: 2017/04/05 17:09:22;  author: root;  state: Exp;  lines: +4 -0
added insertionsort and shiftnode prototypes
—————————-
revision 1.2
date: 2017/04/05 05:13:24;  author: root;  state: Exp;  lines: +40 -26
updated the functions prototypes
—————————-
revision 1.1
date: 2017/03/30 15:08:24;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: struct.h,v
Working file: struct.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file contains the structures
—————————-
revision 1.1    locked by: root;
date: 2017/03/30 15:09:02;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Tagged | Leave a comment

Process Duplication using fork()

Process Duplication is the the duplication of a currently running process.

After duplicating a process, both the processes share the same process context, that means both using the same code segment but both having their own data space, file descriptors & PCB (Process Control Block).

Every process which initiates at any time has its own PCB which stores the information like PID (Process Identifier), PPID (Parent Process Identifier), etc.

pid_t fork(void);

When a parent process calls the fork() then it returns the PID of the new child process created while the call to fork() by child process returns 0.

This return value by fork can be used to differentiate between the parent process and the child process.

Posted in Project 03: Client Server Communication using Linux and IPC | Tagged | Leave a comment

Using getopt() to get options and arguments

The getopt() function is used to get options and arguments and also it checks for an option to be valid or not.

The program shown below gets options -a, -d, -e and options -b & -c with arguments(filename).

//………………………………………………………………………………………………………………………..//

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>

int main(int argc, char *argv[])
{
int opt;

while((opt = getopt(argc,argv,”:ab:c:de”))!=-1)              //check for all options
{
switch(opt)
{
case ‘a’:
case ‘d’:
case ‘e’:
printf(“option : %c\n”,opt);
break;
case ‘c’:
case ‘b’:
printf(“filename : %s\n”,optarg);
break;
case ‘:’:
printf(“option needs a value\n”);
break;
case ‘?’:
printf(“unknown option : %c\n”,optopt);
break;
}
}
for(;optind<argc;optind++)      //after all options, rest are arguments
{
printf(“argument : %s\n”,argv[optind]);
}

return 0;
}

Posted in Uncategorized | Tagged | Leave a comment

Creating LINK LIST and perform the operation of inserting nodes at the end of link list also perform traversing of link list

IN THE FUNCTION creat_nod() CREATING A NODE TO BUILD A LINKLIST
RCS file: create_node.c,v
Working file: create_node.c
head: 1.3
branch:
locks: strict
parvinder: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
crt node
—————————-
revision 1.3 locked by: parvinder;
date: 2017/04/02 08:54:23; author: parvinder; state: Exp; lines: +1 -1
creating a node to creat a link list
in the function by passing a * as a argument nd create a node
—————————-
revision 1.2
date: 2017/04/02 07:08:01; author: parvinder; state: Exp; lines: +13 -7
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:00; author: parvinder; state: Exp;
Initial revision
=============================================================================
TO INSERT A NOD AT THE BIGGNING OF A LINK LIST
RCS file: insertbeg.c,v
Working file: insertbeg.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at the beggining of a link list
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:47:30; author: parvinder; state: Exp;
Initial revision
=============================================================================
TO INSERT AT THE END
RCS file: insertend.c,v
Working file: insertend.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 07:08:26; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertkey.c,v
Working file: insertkey.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
search akey value of node and insert the node in that position
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:48:05; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertmenu.c,v
Working file: insertmenu.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 07:08:26; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertnth.c,v
Working file: insertnth.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at nth position of link list
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:48:43; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.3
branch:
locks: strict
parvinder: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
main prog.
—————————-
revision 1.3 locked by: parvinder;
date: 2017/04/02 08:55:29; author: parvinder; state: Exp; lines: +2 -1
main function cllong the operations what the requirement of user nd switch case acoarding to user’s choice
—————————-
revision 1.2
date: 2017/04/02 07:08:27; author: parvinder; state: Exp; lines: +12 -6
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:10; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
func main menu
—————————-
revision 1.1 locked by: parvinder;
date: 2017/03/27 16:05:20; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: oprations.c,v
Working file: oprations.c
head: 1.2
branch:
locks: strict
parvinder: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
operations
—————————-
revision 1.2 locked by: parvinder;
date: 2017/04/02 07:08:28; author: parvinder; state: Exp; lines: +20 -4
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:31; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: travers.c,v
Working file: travers.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 07:08:28; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: create_node.c,v
Working file: create_node.c
head: 1.3
branch:
locks: strict
parvinder: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
crt node
—————————-
revision 1.3 locked by: parvinder;
date: 2017/04/02 08:54:23; author: parvinder; state: Exp; lines: +1 -1
creating a node to creat a link list
in the function by passing a * as a argument nd create a node
—————————-
revision 1.2
date: 2017/04/02 07:08:01; author: parvinder; state: Exp; lines: +13 -7
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:00; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertbeg.c,v
Working file: insertbeg.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at the beggining of a link list
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:47:30; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertend.c,v
Working file: insertend.c
head: 1.2
branch:
locks: strict
parvinder: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
—————————-
revision 1.2 locked by: parvinder;
date: 2017/04/02 09:29:53; author: parvinder; state: Exp; lines: +3 -3
function to insert node at the end of a link list
—————————-
revision 1.1
date: 2017/04/02 07:08:26; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertkey.c,v
Working file: insertkey.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
search akey value of node and insert the node in that position
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:48:05; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertmenu.c,v
Working file: insertmenu.c
head: 1.2
branch:
locks: strict
parvinder: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
—————————-
revision 1.2 locked by: parvinder;
date: 2017/04/02 09:30:23; author: parvinder; state: Exp; lines: +1 -1
displaying a menu of insertion of node
enter the choice by user
—————————-
revision 1.1
date: 2017/04/02 07:08:26; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: insertnth.c,v
Working file: insertnth.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at nth position of link list
—————————-
revision 1.1 locked by: parvinder;
date: 2017/04/02 08:48:43; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.3
branch:
locks: strict
parvinder: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
main prog.
—————————-
revision 1.3 locked by: parvinder;
date: 2017/04/02 08:55:29; author: parvinder; state: Exp; lines: +2 -1
main function cllong the operations what the requirement of user nd switch case acoarding to user’s choice
—————————-
revision 1.2
date: 2017/04/02 07:08:27; author: parvinder; state: Exp; lines: +12 -6
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:10; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.1
branch:
locks: strict
parvinder: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
func main menu
—————————-
revision 1.1 locked by: parvinder;
date: 2017/03/27 16:05:20; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: oprations.c,v
Working file: oprations.c
head: 1.3
branch:
locks: strict
parvinder: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
operations
—————————-
revision 1.3 locked by: parvinder;
date: 2017/04/02 09:31:09; author: parvinder; state: Exp; lines: +7 -7
emplimenting all the operatins of link list
—————————-
revision 1.2
date: 2017/04/02 07:08:28; author: parvinder; state: Exp; lines: +20 -4
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/27 16:05:31; author: parvinder; state: Exp;
Initial revision
=============================================================================

RCS file: travers.c,v
Working file: travers.c
head: 1.2
branch:
locks: strict
parvinder: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
—————————-
revision 1.2 locked by: parvinder;
date: 2017/04/02 09:31:40; author: parvinder; state: Exp; lines: +1 -1
function of traversing the link list
—————————-
revision 1.1
date: 2017/04/02 07:08:28; author: parvinder; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Creating Linklist & insert nodes in linklist

RCS file: create_node.c,v
Working file: create_node.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
creating node in the linklist
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:11:24; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insert_beg.c,v
Working file: insert_beg.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node in the begining off linklist
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:11:44; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insert_end.c,v
Working file: insert_end.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at the end of linklist
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:12:06; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insert_key.c,v
Working file: insert_key.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node after the key value
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:12:27; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insertmenu.c,v
Working file: insertmenu.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
displays the inserting option.
in this menulist shown where to insert node
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:13:10; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insert_nth.c,v
Working file: insert_nth.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
insert node at desired or nth location
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:14:02; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: insert_oper.c,v
Working file: insert_oper.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
all operation off insert are displaying here
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:14:44; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
this is the main program file
which calls the function
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:15:21; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
a list of menu displays here
—————————-
revision 1.2 locked by: root;
date: 2017/04/02 05:20:42; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.1
date: 2017/04/02 05:16:13; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: operation.c,v
Working file: operation.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
operation to be implemented are displaying here
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:16:44; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: traverse.c,v
Working file: traverse.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
it displays the all elements of linklist
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:17:18; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
all header files are included here
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:17:47; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: prototype.h,v
Working file: prototype.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
all functions are declared here
—————————-
revision 1.1 locked by: root;
date: 2017/04/02 05:18:08; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Access to any location in N-dim. array using pointer.

Memory allocated to array is continuous, so we can access to any location by using a simple pointer.
Such as we have an example.
we want to go to the location g[0][0][0][0][3][4]
the memory allocated is g[5][5][5][5][5][5]
/* We know that memory allocated to array in stack is continuous, it is allocated like this ie x[a=5][b=5]c=[5]= x[0][0][0],x[0][0][1],..x[0][0][4],x[0][1][0],x[0][1][1],..x[0][2][0],……x[1][0][0],x[1][0][1],…..x[1][1][0]..,x[4][4][4] , so we can access to any location by simple pointer of same type as array in this way.. p=p+(value of(c)+(value of (b)*5{size of previous 1d array})+(value of(a)*5*5{size of previous 2d array} )) .*/

to see the programme follow the link

https://drive.google.com/drive/folders/0B-dkmspcBW7aOGhEU2YwTEdLSnM?usp=sharing

Posted in Uncategorized | Tagged | Leave a comment

Deleting An element in Array

#include

int main()
{
int array[100], position, c, n;

printf("Enter number of elements in array\n");
scanf("%d", &n);

printf("Enter %d elements\n", n);

for ( c = 0 ; c = n+1 )
printf("Deletion not possible.\n");
else
{
for ( c = position - 1 ; c < n - 1 ; c++ )
array[c] = array[c+1];

printf("Resultant array is\n");

for( c = 0 ; c < n - 1 ; c++ )
printf("%d\n", array[c]);
}

return 0;
}

Posted in Uncategorized | Leave a comment

3-D Array using pointer

You might have studied  about 1D array or 2D arrays by taking an array of size arr[n] or arr[m][n] respectively.

But, what if I say you have to create a 3-Dimensional array using a pointer?

So let’s start discussing from the very basic . An array is a collection of  elements of similar data types. A single dimensional array consists of ‘n’ number of elements.

A 2-Dimensional array consists of ‘m’ number of 1-Dimensional arrays. Similarly, a 3-Dimensional array contains ‘k’ number of 2-Dimensional arrays and so on.

When using a pointer to create the 3-D array, first of all we need  to allocate a continuous memory to store the array elements using malloc() and the size of the memory(in bytes) to be allocated can be calculated using the following expression–>sizeof(data type)*(row*col*num_2d)

data_type *ptr = data_type *(data_type)malloc(sizeof(data_type)*(row*col*num_2d))

where, sizeof(data_type) is the size(in bytes) of a single element to be stored in the array, row & col are the number of rows and columns in a single 2-D array and num_2d is the total number of 2-D arrays to be stored in the complete 3-D array.

The elements can be stored in the allocated memory locations using the following expression

(ptr+(k*(size_of_2d_array)+(i*size_of_1d_array)+j)

where, ‘ptr’ is the starting address from where the array starts, ‘k’ points to the starting of a single 2-D array, ‘i’ points to the starting of a single 1-D array and ‘j’ is the index value where the element is to be placed.

Similarly, the element can be taken out of these locations by simply putting a *(star or asterisk) in front of above expression.

*(ptr+(k*(size_of_2d_array)+(i*size_of_1d_array)+j)

Below is the sample code to create and print the elements of a 3-D array.

//………………………………………………………………………………………………………………………………..//

#include<stdio.h>
#include<stdlib.h>
//………………………………………………..Functions Declaration…………………………………………….//
int getarray();
int disparray(int *, int, int, int);
int getelements(int *, int, int, int);
//………………………………………………………………………………………………………………………………..//

//…………………………………………………Function Pointer Declaration……………………………………//
int (*garray)();
int (*darray)(int *, int, int, int);
int (*gel)(int *, int, int, int);
//………………………………………………………………………………………………………………………………..//

//……………………………………………………..MAIN BEGIN…………………………………………………….//

int main()
{
//……………………………………defining function pointer……………………………….
garray = getarray;
darray = disparray;
gel =getelements;
//…………………………………………………………………………………………..
int *arr_ptr;

garray();       //get array size from the user
return 0;
}

//……………………………………………………..MAIN END…………………………………………………….//

//…………………………………………………Func to get array size…………………………………………..//

int getarray()
{
int row, col, i, j, num_2d, k;
int *arr_ptr;

printf(“Enter the number of rows and columns in the 2D array\n”);
scanf(“%d%d”,&row, &col);       //getting num of rows & cols in single 2D array

printf(“Enter the number of 2D arrays in 3D array\n”);
scanf(“%d”,&num_2d);            //getting total num of 2D arrays in complete 3D array

arr_ptr = (int*)malloc(sizeof(int)*(row*col*num_2d));           //allocating continuous memory to the complete 3D array

gel(arr_ptr,row,col,num_2d);           //calling getelements() to get array elements

darray(arr_ptr,row,col,num_2d);         //calling disparray() to diplay the array elements

return 0;
}

//…………………………………………..Func to get array elements…………………………………………//

int getelements(int *arr_ptr, int row, int col, int num_2d)

{
int i, j, k;

for(k=0;k<num_2d;k++)
{
printf(“\n\t…………Enter the elements of 2D array………….. %d\n”,k+1);
for(i=0;i<row;i++)
{
printf(“Enter the elements of row %d\n”,i+1);
for(j=0;j<col;j++)
{
scanf(“%d”,(arr_ptr+(k*(sizeof(int)*row*col))+(i*sizeof(int)*col)+j));  //getting the array elements from the user
}
}
}
return 0;
}

//……………………………………….Func to display array elements………………………………………//

int disparray(int *arr_ptr, int row, int col, int num_2d)

{
int i,j,k;

printf(“Elements of 3D array are\n\t”);

for(k=0;k<num_2d;k++)
{
printf(“\t………..2D array %d………\n\t”,k+1);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf(“%d\t”,*(arr_ptr+(k*(sizeof(int)*row*col))+(i*sizeof(int)*col)+j));
}
printf(“\n\t”);
}
printf(“\n\n\t”);
}

return 0;
}

//………………………………………………………………………………………………………………………………..//

 

Posted in Uncategorized | Tagged | Leave a comment

Multiple Data Compression & Encryption Using Iterartive Technique(2,3,4,5,6 & 7 bit compression & decompression) make & RCS

RCS file: codelength.c,v
Working file: codelength.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
this func finds the code length
—————————-
revision 1.4    locked by: root;
date: 2017/03/15 17:13:17;  author: root;  state: Exp;  lines: +2 -2
added comments
—————————-
revision 1.3
date: 2017/03/08 10:53:35;  author: root;  state: Exp;  lines: +1 -1
print code length
—————————-
revision 1.2
date: 2017/03/08 10:03:22;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:46:07;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress2.c,v
Working file: compress2.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
this func compress the files with code length = 2
—————————-
revision 1.4    locked by: root;
date: 2017/03/28 16:26:49;  author: root;  state: Exp;  lines: +67 -1
added 11 at the end of the compressed file to show end of file
—————————-
revision 1.3
date: 2017/03/08 10:54:05;  author: root;  state: Exp;  lines: +1 -1
no change
—————————-
revision 1.2
date: 2017/03/08 09:58:15;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:46:30;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress3.c,v
Working file: compress3.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this func compress the files with code length = 3
—————————-
revision 1.3    locked by: root;
date: 2017/03/28 16:28:56;  author: root;  state: Exp;  lines: +135 -2
added 111 at the end of the compressed file to show end of file
—————————-
revision 1.2
date: 2017/03/08 09:58:41;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:47:17;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress4.c,v
Working file: compress4.c
head: 1.32
branch:
locks: strict
root: 1.32
access list:
symbolic names:
keyword substitution: kv
total revisions: 32;    selected revisions: 32
description:
this func compress the files with code length = 4
—————————-
revision 1.32    locked by: root;
date: 2017/03/28 16:29:08;  author: root;  state: Exp;  lines: +8 -40
added 1111 at the end of the compressed file to show end of file
—————————-
revision 1.31
date: 2017/03/16 10:05:38;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.30
date: 2017/03/16 09:50:43;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.29
date: 2017/03/16 06:14:23;  author: root;  state: Exp;  lines: +0 -2
*** empty log message ***
—————————-
revision 1.28
date: 2017/03/16 04:00:03;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.27
date: 2017/03/15 18:44:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.26
date: 2017/03/15 18:42:35;  author: root;  state: Exp;  lines: +3 -2
*** empty log message ***
—————————-
revision 1.25
date: 2017/03/15 18:36:03;  author: root;  state: Exp;  lines: +6 -1
*** empty log message ***
—————————-
revision 1.24
date: 2017/03/15 18:32:43;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.23
date: 2017/03/15 18:31:11;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.22
date: 2017/03/15 17:42:35;  author: root;  state: Exp;  lines: +6 -0
*** empty log message ***
—————————-
revision 1.21
date: 2017/03/15 17:26:03;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.20
date: 2017/03/15 17:23:57;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2017/03/15 17:23:01;  author: root;  state: Exp;  lines: +3 -2
*** empty log message ***
—————————-
revision 1.18
date: 2017/03/15 17:13:49;  author: root;  state: Exp;  lines: +12 -15
added option to get output file name and directory from user
—————————-
revision 1.17
date: 2017/03/15 14:44:51;  author: root;  state: Exp;  lines: +40 -13
changes in compression process
—————————-
revision 1.16
date: 2017/03/08 11:56:38;  author: root;  state: Exp;  lines: +0 -4
syntax errors
—————————-
revision 1.15
date: 2017/03/08 11:54:14;  author: root;  state: Exp;  lines: +5 -5
*** empty log message ***
—————————-
revision 1.14
date: 2017/03/08 11:52:52;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.13
date: 2017/03/08 11:52:03;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.12
date: 2017/03/08 11:51:31;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.11
date: 2017/03/08 11:47:58;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.10
date: 2017/03/08 11:35:47;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.9
date: 2017/03/08 11:33:43;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.8
date: 2017/03/08 11:31:51;  author: root;  state: Exp;  lines: +3 -1
*** empty log message ***
—————————-
revision 1.7
date: 2017/03/08 11:18:15;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.6
date: 2017/03/08 11:11:39;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.5
date: 2017/03/08 11:06:51;  author: root;  state: Exp;  lines: +2 -1
declared byt as unsigned char
—————————-
revision 1.4
date: 2017/03/08 11:04:41;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.3
date: 2017/03/08 10:54:17;  author: root;  state: Exp;  lines: +41 -4
compressed file for 4 code length
—————————-
revision 1.2
date: 2017/03/08 09:58:46;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:47:23;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress5.c,v
Working file: compress5.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this func compress the files with code length = 5
—————————-
revision 1.3    locked by: root;
date: 2017/03/28 16:29:19;  author: root;  state: Exp;  lines: +146 -2
added 11111 at the end of the compressed file to show end of file
—————————-
revision 1.2
date: 2017/03/08 09:58:50;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:47:29;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress6.c,v
Working file: compress6.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this func compress the files with code length = 6
—————————-
revision 1.3    locked by: root;
date: 2017/03/28 16:29:35;  author: root;  state: Exp;  lines: +82 -2
added 111111 at the end of the compressed file to show end of file
—————————-
revision 1.2
date: 2017/03/08 09:58:52;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:47:37;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compress7.c,v
Working file: compress7.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
this func compress the files with code length = 7
—————————-
revision 1.3    locked by: root;
date: 2017/03/28 16:29:46;  author: root;  state: Exp;  lines: +165 -2
added 1111111 at the end of the compressed file to show end of file
—————————-
revision 1.2
date: 2017/03/08 09:58:55;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/08 09:47:42;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: compression.c,v
Working file: compression.c
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
this func compresses the file
—————————-
revision 1.8    locked by: root;
date: 2017/03/28 16:29:55;  author: root;  state: Exp;  lines: +77 -8
added feature to get name of file to be compressed from user
—————————-
revision 1.7
date: 2017/03/15 17:14:45;  author: root;  state: Exp;  lines: +3 -12
removed previous function pointer declarations
—————————-
revision 1.6
date: 2017/03/15 14:45:46;  author: root;  state: Exp;  lines: +20 -8
opened file before calling compression()
—————————-
revision 1.5
date: 2017/03/08 11:48:00;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.4
date: 2017/03/08 10:03:34;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.3
date: 2017/03/08 09:53:40;  author: root;  state: Exp;  lines: +4 -1
printed codelength and master array
—————————-
revision 1.2
date: 2017/03/08 09:47:47;  author: root;  state: Exp;  lines: +27 -2
called different compress()’s for different code lenghts
—————————-
revision 1.1
date: 2017/03/07 07:55:35;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress2.c,v
Working file: decompress2.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 2
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:30:38;  author: root;  state: Exp;  lines: +42 -1
added feature to show end of file on receiving 11 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:46:20;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress3.c,v
Working file: decompress3.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 3
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:32:51;  author: root;  state: Exp;  lines: +77 -1
added feature to show end of file on receiving 111 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:46:57;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress4.c,v
Working file: decompress4.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 4
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:33:03;  author: root;  state: Exp;  lines: +7 -16
added feature to show end of file on receiving 1111 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:47:02;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress5.c,v
Working file: decompress5.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 5
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:33:20;  author: root;  state: Exp;  lines: +95 -3
added feature to show end of file on receiving 11111 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:47:06;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress6.c,v
Working file: decompress6.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 6
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:33:34;  author: root;  state: Exp;  lines: +53 -3
added feature to show end of file on receiving 111111 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:47:12;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompress7.c,v
Working file: decompress7.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
decompress process for codelength 7
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:33:51;  author: root;  state: Exp;  lines: +91 -3
added feature to show end of file on receiving 1111111 from compressed file
—————————-
revision 1.1
date: 2017/03/15 14:47:17;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: decompression.c,v
Working file: decompression.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this is the func for decompression of compressed file
—————————-
revision 1.2    locked by: root;
date: 2017/03/28 16:34:04;  author: root;  state: Exp;  lines: +92 -19
added feature to get name of file to be decompressed from the user
—————————-
revision 1.1
date: 2017/03/15 14:47:20;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: functionspointers.c,v
Working file: functionspointers.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
this func initalizes pointer to all the functions used in the project
—————————-
revision 1.2    locked by: root;
date: 2017/03/15 17:15:28;  author: root;  state: Exp;  lines: +1 -0
added getfilename pointer
—————————-
revision 1.1
date: 2017/03/15 14:47:48;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: getfilename.c,v
Working file: getfilename.c
head: 1.26
branch:
locks: strict
root: 1.26
access list:
symbolic names:
keyword substitution: kv
total revisions: 26;    selected revisions: 26
description:
func to get output filenames from user
—————————-
revision 1.26    locked by: root;
date: 2017/03/28 16:34:58;  author: root;  state: Exp;  lines: +4 -21
this func gets the name of file to work on from the user
—————————-
revision 1.25
date: 2017/03/16 11:17:16;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.24
date: 2017/03/16 10:05:39;  author: root;  state: Exp;  lines: +13 -3
*** empty log message ***
—————————-
revision 1.23
date: 2017/03/16 09:49:28;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.22
date: 2017/03/16 09:45:02;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.21
date: 2017/03/16 09:41:20;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.20
date: 2017/03/16 09:08:25;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2017/03/16 09:07:01;  author: root;  state: Exp;  lines: +5 -2
*** empty log message ***
—————————-
revision 1.18
date: 2017/03/16 09:01:49;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.17
date: 2017/03/16 08:58:49;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.16
date: 2017/03/16 08:11:44;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.15
date: 2017/03/16 06:36:40;  author: root;  state: Exp;  lines: +3 -5
*** empty log message ***
—————————-
revision 1.14
date: 2017/03/16 06:18:47;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.13
date: 2017/03/16 06:17:10;  author: root;  state: Exp;  lines: +2 -1
*** empty log message ***
—————————-
revision 1.12
date: 2017/03/16 06:14:25;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.11
date: 2017/03/15 18:23:50;  author: root;  state: Exp;  lines: +3 -2
*** empty log message ***
—————————-
revision 1.10
date: 2017/03/15 18:21:00;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2017/03/15 17:56:09;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.8
date: 2017/03/15 17:53:35;  author: root;  state: Exp;  lines: +3 -3
*** empty log message ***
—————————-
revision 1.7
date: 2017/03/15 17:51:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.6
date: 2017/03/15 17:50:16;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.5
date: 2017/03/15 17:46:50;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2017/03/15 17:42:37;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.3
date: 2017/03/15 17:24:41;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2017/03/15 17:23:03;  author: root;  state: Exp;  lines: +4 -4
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/15 17:15:47;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: locsearch.c,v
Working file: locsearch.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
finds the location of the character read from file in the master array
—————————-
revision 1.4    locked by: root;
date: 2017/03/08 11:57:57;  author: root;  state: Exp;  lines: +0 -2
removed begin and end print
—————————-
revision 1.3
date: 2017/03/08 11:31:53;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.2
date: 2017/03/08 11:20:48;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.1
date: 2017/03/08 10:54:50;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: main.c,v
Working file: main.c
head: 1.9
branch:
locks: strict
root: 1.9
access list:
symbolic names:
keyword substitution: kv
total revisions: 9;    selected revisions: 9
description:
this is the main func of the program
—————————-
revision 1.9    locked by: root;
date: 2017/03/28 16:44:14;  author: root;  state: Exp;  lines: +1 -1
added main : End statement
—————————-
revision 1.8
date: 2017/03/28 16:40:14;  author: root;  state: Exp;  lines: +0 -12
removed some comments
—————————-
revision 1.7
date: 2017/03/28 16:35:32;  author: root;  state: Exp;  lines: +8 -20
now main doesn’t take filename as an argument but it is taken inside the getfilename()
—————————-
revision 1.6
date: 2017/03/15 14:48:26;  author: root;  state: Exp;  lines: +40 -21
called funcptr
—————————-
revision 1.5
date: 2017/03/07 07:56:16;  author: root;  state: Exp;  lines: +1 -6
removed readfile() from main & called it inside the compression func
—————————-
revision 1.4
date: 2017/03/07 06:06:58;  author: root;  state: Exp;  lines: +12 -12
added comments
—————————-
revision 1.3
date: 2017/03/06 12:05:10;  author: root;  state: Exp;  lines: +2 -2
commented compression()
—————————-
revision 1.2
date: 2017/03/06 12:01:26;  author: root;  state: Exp;  lines: +18 -0
added switch case on receiving choice
—————————-
revision 1.1
date: 2017/03/06 11:23:01;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: mainmenu.c,v
Working file: mainmenu.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
this func displays the different choices to the user
—————————-
revision 1.5    locked by: root;
date: 2017/03/16 06:14:25;  author: root;  state: Exp;  lines: +3 -2
*** empty log message ***
—————————-
revision 1.4
date: 2017/03/15 14:49:22;  author: root;  state: Exp;  lines: +16 -11
changed simple printf statements to printing options using pointer
—————————-
revision 1.3
date: 2017/03/07 04:55:38;  author: root;  state: Exp;  lines: +1 -1
added statement to print on receiving wrong choice
—————————-
revision 1.2
date: 2017/03/07 04:41:56;  author: root;  state: Exp;  lines: +6 -3
added comments
—————————-
revision 1.1
date: 2017/03/06 11:24:22;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: masterarray.c,v
Working file: masterarray.c
head: 1.9
branch:
locks: strict
root: 1.9
access list:
symbolic names:
keyword substitution: kv
total revisions: 9;    selected revisions: 9
description:
this func creates the master array of unique characters
—————————-
revision 1.9    locked by: root;
date: 2017/03/28 16:37:26;  author: root;  state: Exp;  lines: +2 -2
instead of reading only one line , now the master array is created from complete file till end
—————————-
revision 1.8
date: 2017/03/15 17:16:15;  author: root;  state: Exp;  lines: +4 -4
added comments
—————————-
revision 1.7
date: 2017/03/15 14:50:38;  author: root;  state: Exp;  lines: +7 -3
func to create master array
—————————-
revision 1.6
date: 2017/03/08 10:55:19;  author: root;  state: Exp;  lines: +0 -1
print master array
—————————-
revision 1.5
date: 2017/03/08 08:57:53;  author: root;  state: Exp;  lines: +6 -1
added realloc() failure condition
—————————-
revision 1.4
date: 2017/03/08 08:52:58;  author: root;  state: Exp;  lines: +3 -4
added realloc() to create array of characters instead of using malloc()
—————————-
revision 1.3
date: 2017/03/07 08:16:39;  author: root;  state: Exp;  lines: +4 -2
changes the while loop condition to while(1) from while(count)
—————————-
revision 1.2
date: 2017/03/07 08:03:40;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.1
date: 2017/03/07 07:57:11;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: openfile.c,v
Working file: openfile.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
this func checks for the filename given by user and if valid returns a file descripter
—————————-
revision 1.4    locked by: root;
date: 2017/03/07 08:01:54;  author: root;  state: Exp;  lines: +1 -1
syntax error
—————————-
revision 1.3
date: 2017/03/07 07:57:41;  author: root;  state: Exp;  lines: +9 -3
added some comments
—————————-
revision 1.2
date: 2017/03/07 04:42:08;  author: root;  state: Exp;  lines: +5 -5
added comments
—————————-
revision 1.1
date: 2017/03/06 11:25:07;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: unique.c,v
Working file: unique.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
this func checks for the character read from file in the memory
—————————-
revision 1.5    locked by: root;
date: 2017/03/08 10:03:43;  author: root;  state: Exp;  lines: +2 -2
removed begin statement
—————————-
revision 1.4
date: 2017/03/08 09:01:23;  author: root;  state: Exp;  lines: +2 -0
added ma == NULL condition
—————————-
revision 1.3
date: 2017/03/07 04:56:54;  author: root;  state: Exp;  lines: +3 -3
changed ptr to ma for showing master array
—————————-
revision 1.2
date: 2017/03/07 04:42:26;  author: root;  state: Exp;  lines: +6 -6
added comments
—————————-
revision 1.1
date: 2017/03/06 12:02:40;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
this file contains all the header file
s
—————————-
revision 1.1    locked by: root;
date: 2017/03/07 05:11:50;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: prototypes.h,v
Working file: prototypes.h
head: 1.10
branch:
locks: strict
root: 1.10
access list:
symbolic names:
keyword substitution: kv
total revisions: 10;    selected revisions: 10
description:
this file contains the declarations of the functions used in the project
—————————-
revision 1.10    locked by: root;
date: 2017/03/28 16:38:47;  author: root;  state: Exp;  lines: +30 -30
declared getfilename()
—————————-
revision 1.9
date: 2017/03/16 10:05:40;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.8
date: 2017/03/15 17:23:05;  author: root;  state: Exp;  lines: +2 -2
*** empty log message ***
—————————-
revision 1.7
date: 2017/03/15 17:16:42;  author: root;  state: Exp;  lines: +2 -0
added getfilename() declaration
—————————-
revision 1.6
date: 2017/03/15 14:51:08;  author: root;  state: Exp;  lines: +36 -0
declared more functions
—————————-
revision 1.5
date: 2017/03/08 10:55:37;  author: root;  state: Exp;  lines: +1 -0
added locsearch()
—————————-
revision 1.4
date: 2017/03/08 09:50:37;  author: root;  state: Exp;  lines: +6 -6
syntax error
—————————-
revision 1.3
date: 2017/03/08 09:48:30;  author: root;  state: Exp;  lines: +7 -0
declared compress()’s
—————————-
revision 1.2
date: 2017/03/07 07:58:39;  author: root;  state: Exp;  lines: +2 -1
added masterarray() & compression()
—————————-
revision 1.1
date: 2017/03/07 05:12:19;  author: root;  state: Exp;
Initial revision
=============================================================================

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

Linked list

A Linked list is a sequence of data structures connected together via links. Each link in the linked list contains a data element and a connection to the next link.

The linked lists are most widely used in the application programming and the system programming. The linked list can have atleast one to a number of nodes in it. A new node can be inserted at beginning of the list, end of the list or anywhere in between the two nodes where we want it to be inserted.

The most common use of the link list is during the system boot (or wakeup), when we start our system a number of functions (or programs) are called and a number of parameters are checked. All this is done in a sequence everytime and this sequence is created using link list.

Follow the link below to see the program that creates a linklist, inserts a new node anywhere you want to, delete any node & traverse (display) the elements in the link list.

https://drive.google.com/drive/folders/0B7IuBrNROxFhbkU1Qm5zbG1Bakk?usp=sharing

Posted in Data Structures with C | Tagged | Leave a comment

Binary Search

Searching is one of the most important task for any programmer. We have too many techniques to do this ,among all the techniques we are using Binary search right now because
Binary search is too good for searching a number in a large number-list it takes less time.
The necessary condition to perform Binary search is that the list should be Shorted.
Algo:
It break down the list in to two parts in every iteration
the number you want to search is compare with lowest number , middle number, largest number of the shorted list,
*if the number you want to search is less then the middle number then
lowest number will be same
the previous middle number will be consider as largest
new middle number will be assigned using ((a+b)/2)
// because number is greater then the lowest number but less the the middle number , so no need to . search it in a number range above the middle number.
*if the number you want to search is greater then the middle number then
largest number will be same
the previous middle number will be consider as smallest
new middle number will be assigned using ((a+b)/2)
// because number is greater then the middle number but less then the largest number , so no need to . search it in a number range below the middle number.

see the Programme
follow the link.

https://drive.google.com/drive/folders/0B-dkmspcBW7aZnRVZTM5NklELTA?usp=sharing

Posted in Uncategorized | Tagged , | Leave a comment

Program to Multiply Two 3 X 3 Matrices


#include

int main() {
int a[10][10], b[10][10], c[10][10], i, j, k;
int sum = 0;

printf("\nEnter First Matrix : n");
for (i = 0; i <3; i++) {
for (j = 0; j < 3; j++) {
scanf("%d", &a[i][j]);
}
}

printf("\nEnter Second Matrix:n");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
scanf("%d", &b[i][j]);
}
}

printf("The First Matrix is: \n";);
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf(" %d ", a[i][j]);
}
printf("\n");
}

printf("The Second Matrix is : \n");
for (i = 0; i< 3; i++) {
for (j = 0; j < 3; j++) {
printf(" %d" , b[i][j]);
}
printf("\n");
}

//Multiplication Logic
for (i = 0; i <= 2; i++) {
for (j = 0; j <= 2; j++) {
sum = 0;
for (k = 0; k <= 2; k++) {
sum = sum + a[i][k] * b[k][j];
}
c[i][j] = sum;
}
}

printf("\nMultiplication Of Two Matrices : );
for (i = 0; i <3; i++) {
for (j = 0; j< 3; j++) {
printf("%d" , c[i][j]);
}
printf("\n");
}

return (0);
}

Posted in Uncategorized | Leave a comment

Swap / Interchange two variables without using Third Variable

#include

int main() {
int num1, num2;

printf(“\nEnter First Number : “);
scanf(“%d”, &num1);

printf(“\nEnter Second Number : “);
scanf(“%d”, &num2);

num1 = num1 ^ num2;
num2 = num1 ^ num2;
num1 = num1 ^ num2;

printf(“\n Numbers after Exchange : “);
printf(“\n Num1 = %d and Num2 = %d”, num1, num2);

return(0);
}

Posted in Uncategorized | Leave a comment