EmbLogic's Blog

creating nodes…

RCS file: ./linklist.c,v
Working file: ./linklist.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
declare the header file and also delcare the structure in the head.h file
co linklist.c
—————————-
revision 1.3 locked by: root;
date: 2015/03/29 12:21:00; author: root; state: Exp; lines: +2 -2
put the choice into while loop
and make switch cases here
int case first make a inesrt node function
and declare it
then invoke it into first case
then we create the nuber of nodes here
—————————-
revision 1.2
date: 2015/03/29 12:18:42; author: root; state: Exp; lines: +2 -1
take a integer varible choice
then create the a menu list
give the numbering to the choice that 1 for create a node
2 for insert the node
—————————-
revision 1.1
date: 2015/03/29 12:17:20; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

communication through fifo using one client

RCS file: fifo.c,v
Working file: fifo.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
include all the headerfile and also declare the struct in the header.h file
—————————-
revision 1.4 locked by: root;
date: 2015/03/27 11:30:46; author: root; state: Exp; lines: +2 -2
open the fifo into write only mode and write result into the fifo
for requesting and in requesting read the result from fifo
—————————-
revision 1.3
date: 2015/03/27 11:27:13; author: root; state: Exp; lines: +3 -3
creat a pipe between server and clint process
give the execl call in the child secton
and pass the descriptor fir reading and writing
then write the structure into pipe for processing
affter processing reading the result from pipe into server
—————————-
revision 1.2
date: 2015/03/27 11:18:51; author: root; state: Exp; lines: +2 -2
declare the varible which is required
create a fifo and open the fifo in reading mode
read the structure from requesting fifo and close the fifo here.
—————————-
revision 1.1
date: 2015/03/27 11:17:00; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

THE LINUX FIRE WALL

 

If we talk about firewall the first thing that comes to our mind is a software “Barrier” between a system and a network it may be either internal or external. The purpose of this software is to protect our system from various threats. This network security system, can be used to control incoming and outgoing network traffic based on a specific set of rules. This firewall can be used in various devices like routers .

Now if we talk about it is a kernel (or in other word a piece of software )acting on hardware.

So the kernel provides us with XTABLES which stores chins and all the rule ,act as a firewall in system. XTABLE consist of different modules for different protocols. The various modules are:-

1 > iptables applies to IPv4

2> ip6tables to IPv6

3> arptables to ARP

4> ebtables for Ethernet frames

SO our current focus will be on iptables ,what is IPTABLES ???

Its a built in firewall application fro configuring the tables provided by the LINUX KERNEL FIREWALL . Two major things associated with these utilities or application are its chain and rule.

iptables is command that uses the concept of chains to handle the network traffic .It places the rules into chains which are checked against the network traffic.Decisions are made as to what to do with the packets based on these rules (i.e whether the packet should be accepted or dropped). The predefined chains  are as follows

PREROUTING: Packets will enter this chain before a routing decision is made.

INPUT: Packet is going to be locally delivered. It does not have anything to do with processes having an opened socket; local delivery is controlled by the “local-delivery” routing table: ip route show table local.

FORWARD: All packets that have been routed and were not for local delivery will traverse this chain.

OUTPUT: Packets sent from the machine itself will be visiting this chain.

POSTROUTING: Routing decision has been made. Packets enter this chain just before handing them off to the hardware.

Tables associated with Iptables are :-

Filter table , NAT table, Raw Table, Mangle Table

Rules are :- ACCEPT , DROP, QUEUE, RETURN

Their are various flags associated with iptables like

-A      to add a rule

-p      to indicate the protocol

-s       to indicate the source of packet

-d      to indicate the destination

-dport    port number of the destination port

-sport     port number of the source port

their are various other flags for which u can refer the man page

You can use the iptables service using command:-

service iptables start/stop/restart/status

 

 

Posted in Linux Internals and System Programming, Project 00: Linux System / Network Administration | Leave a comment

orphan state

head 1.1;
access;
symbols;
locks
ashish:1.1; strict;
comment @ * @;

1.1
date 2015.03.24.13.44.13; author ashish; state Exp;
branches;
next ;

desc
@programme for orphan condition where the child terminates after the termination of parents,
where the child beacme the orphan
@

1.1
log
@Initial revision
@
text
@#include
#include
#include
#include

int main()

{

char *lines;
int n;
pid_t pid;
printf(“its starting\n”);
pid=fork();
printf(“pid->%d\n”,pid);

switch(pid)
{

case -1: printf (“error\n”);
break;

case 0: lines=”mmm child”;
printf(“child id is:%d\t %d\n”,getpid(),getppid());
n=7;
break;
//its orphan state because here child s going to be terminate after the parent….so the child would be orphan here..//

default: lines=”mm parent”;
printf(“parent id is :%d\n”,getppid());
n=5;
break;

}

for(;n>0;n–)
{
puts(lines);
printf(“%s:my id:%d \t my parent pid is %d\n”,lines,getpid(),getppid());

//sleep(1);
}//child became orphan and it will terminate with pid of init process//
exit(0);
}

@

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

USE OF atexit()

head 1.3;
access;
symbols;
locks
ashish:1.3; strict;
comment @ * @;

1.3
date 2015.03.24.12.56.57; author ashish; state Exp;
branches;
next 1.2;

1.2
date 2015.03.24.12.54.03; author ashish; state Exp;
branches;
next 1.1;

1.1
date 2015.03.24.12.53.35; author ashish; state Exp;
branches;
next ;

desc
@programme to use atexit()
@

1.3
log
@now calling the atexit(),from the main(),where the function declared above will be passed as an argu to this function
checking the condition for succeding this func
then if it succed then the ext(),will be called and then final exit would be done

@

1.2
log
@declaring header files
now giving the defination of a function ,which will be called at the time of exit
@
text
@a2 1
///#include
@

1.1
log
@Initial revision
@
text
@d3 1
a3 1
//#include
@

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

USING WAIT WHILE DOING MULTIPLE CHILD AND PARENT

head 1.7;
access;
symbols;
locks
ashish:1.7; strict;
comment @ * @;

1.7
date 2015.03.24.13.22.13; author ashish; state Exp;
branches;
next 1.6;

1.6
date 2015.03.24.13.20.46; author ashish; state Exp;
branches;
next 1.5;

1.5
date 2015.03.24.13.16.32; author ashish; state Exp;
branches;
next 1.4;

1.4
date 2015.03.24.13.14.02; author ashish; state Exp;
branches;
next 1.3;

1.3
date 2015.03.24.13.12.18; author ashish; state Exp;
branches;
next 1.2;

1.2
date 2015.03.24.13.11.36; author ashish; state Exp;
branches;
next 1.1;

1.1
date 2015.03.24.13.10.53; author ashish; state Exp;
branches;
next ;

desc
@@

1.7
log
@now we will use WEXITSTATUS(),where it willl fetch the code with which the child have been terminated.

@

1.6
log
@now using the fun WIFEXITED(),where it will take the variable in its argu to point where the exit code have been stored

@

1.5
log
@now taking a if(),condition which will run when the value return by the fork() would be greater than the 0,i.e for parent
where a c1pid variable of prototype pid_t have been declared which will get the return pid of child when it will terminate by giving the wait() to parent so that parent can wait,and child can terminate normally
@
text
@a16 1

@

1.4
log
@providing a for loop
where child and parent would execute in sequence by printing their mesages and pids
where pids will be obtained by using getpid(),getppid()
@
text
@a18 1

a21 1

@

1.3
log
@now doing a fork

where the child and parent would be created
now defining the exit code for each of parent and child
@
text
@a8 1

@

1.2
log
@declaring the header files
declaing the variabels
@
text
@a53 1

@

1.1
log
@Initial revision
@
text
@d54 1
@

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

SELECTION SORTING

head 1.5;
access;
symbols;
locks
ashish:1.5; strict;
comment @ * @;

1.5
date 2015.03.23.13.44.10; author ashish; state Exp;
branches;
next 1.4;

1.4
date 2015.03.23.13.42.03; author ashish; state Exp;
branches;
next 1.3;

1.3
date 2015.03.23.13.40.25; author ashish; state Exp;
branches;
next 1.2;

1.2
date 2015.03.23.13.39.13; author ashish; state Exp;
branches;
next 1.1;

1.1
date 2015.03.23.13.38.06; author ashish; state Exp;
branches;
next ;

desc
@programme for sorting the array by using selection sorting
@

1.5
log
@further process will be done .
displayoing the sorted list.

@

1.4
log
@checking the condition,if the element pointed by the first loop variable is greater thean the element pointed by the second one
if the condition will be true then,only the loop will run
@
text
@a24 1

@

1.3
log
@taking the 2 for loop
first will run from initial position to the end of the length
and second will run from the next pt from the first one up to the last of the length of the array
@
text
@a23 1

@

1.2
log
@taking a array
asking the user to enter the size of array
entering the element of array by the user
@
text
@a22 1

@

1.1
log
@Initial revision
@
text
@d22 1
a22 2

@

Posted in Data Structures with C | Leave a comment

Insertion sorting

head 1.8;
access;
symbols;
locks
ashish:1.8; strict;
comment @ * @;

1.8
date 2015.03.23.13.36.10; author ashish; state Exp;
branches;
next 1.7;

1.7
date 2015.03.23.13.34.43; author ashish; state Exp;
branches;
next 1.6;

1.6
date 2015.03.23.13.33.26; author ashish; state Exp;
branches;
next 1.5;

1.5
date 2015.03.23.13.31.25; author ashish; state Exp;
branches;
next 1.4;

1.4
date 2015.03.23.13.29.32; author ashish; state Exp;
branches;
next 1.3;

1.3
date 2015.03.23.13.27.59; author ashish; state Exp;
branches;
next 1.2;

1.2
date 2015.03.23.13.26.32; author ashish; state Exp;
branches;
next 1.1;

1.1
date 2015.03.23.13.25.39; author ashish; state Exp;
branches;
next ;

desc
@programme for insertion sorting
@

1.8
log
@displaying the sorted list of arrays
@
text
@

1.7
log
@then out of the loop,the element stored in the temp variable will be copied to the position pointed by the j variable
@
text
@d28 1
a28 1

@

1.6
log
@if the condition will be true then the element pointed by the j is copied to the j+1,
and j will be reduced by 1 to its initial value
@
text
@a26 1

@

1.5
log
@copying the first element in a temporary varible say temp
now taking a while loop,which will chek the condition that if the variable in temp is less than the vaible pointed by the j variable to the next of the array
@
text
@a24 1

@

1.4
log
@taking a for loop which will run up to the size of array nd will start from second to start of the array
@
text
@a23 1

@

1.3
log
@displaying the elements entered by the user
@
text
@a20 1

@

1.2
log
@entering array of number from user
@
text
@a19 1

@

1.1
log
@Initial revision

Posted in Data Structures with C | Leave a comment

Successfully done IPC using fifo for 3 requesting and 3 processing clients…..

RCS file: server.c,v
Working file: server.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 base file for ipc using fifo for 3 requesting and 3 processing clients.
—————————-
revision 1.9 locked by: root;
date: 2015/03/25 06:12:20; author: root; state: Exp; lines: +2 -1
Got result back on requesting clients.
—————————-
revision 1.8
date: 2015/03/25 06:11:44; author: root; state: Exp; lines: +1 -2
*** empty log message ***
—————————-
revision 1.7
date: 2015/03/25 06:11:22; author: root; state: Exp; lines: +2 -1
*** empty log message ***
—————————-
revision 1.6
date: 2015/03/25 06:06:54; author: root; state: Exp; lines: +1 -1
Got the result from processing clients using signals.
printed result on server.
—————————-
revision 1.5
date: 2015/03/25 06:05:29; author: root; state: Exp; lines: +0 -2
Forwarded request from server to processing clients via pipes.
printed request on processing clients.
—————————-
revision 1.4
date: 2015/03/25 06:04:17; author: root; state: Exp; lines: +0 -2
Created 3 processing clients using fork() and execl.
Connected processing clients to server via pipes.
—————————-
revision 1.3
date: 2015/03/25 06:03:00; author: root; state: Exp; lines: +1 -1
Created fifo r_fifo.
Sent request from requesting clients to server via fifo.
—————————-
revision 1.2
date: 2015/03/25 05:59:21; author: root; state: Exp; lines: +1 -1
Created 3 requesting clients….
Created server.
—————————-
revision 1.1
date: 2015/03/25 05:58:33; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: server.c,v
Working file: server.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 base file for ipc using fifo for 3 requesting and 3 processing clients.
—————————-
revision 1.9 locked by: root;
date: 2015/03/25 06:12:20; author: root; state: Exp; lines: +2 -1
Got result back on requesting clients.
—————————-
revision 1.8
date: 2015/03/25 06:11:44; author: root; state: Exp; lines: +1 -2
*** empty log message ***
—————————-
revision 1.7
date: 2015/03/25 06:11:22; author: root; state: Exp; lines: +2 -1
*** empty log message ***
—————————-
revision 1.6
date: 2015/03/25 06:06:54; author: root; state: Exp; lines: +1 -1
Got the result from processing clients using signals.
printed result on server.
—————————-
revision 1.5
date: 2015/03/25 06:05:29; author: root; state: Exp; lines: +0 -2
Forwarded request from server to processing clients via pipes.
printed request on processing clients.
—————————-
revision 1.4
date: 2015/03/25 06:04:17; author: root; state: Exp; lines: +0 -2
Created 3 processing clients using fork() and execl.
Connected processing clients to server via pipes.
—————————-
revision 1.3
date: 2015/03/25 06:03:00; author: root; state: Exp; lines: +1 -1
Created fifo r_fifo.
Sent request from requesting clients to server via fifo.
—————————-
revision 1.2
date: 2015/03/25 05:59:21; author: root; state: Exp; lines: +1 -1
Created 3 requesting clients….
Created server.
—————————-
revision 1.1
date: 2015/03/25 05:58:33; author: root; state: Exp;
Initial revision
=============================================================================

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

ipc using threads and messagequeue

head 1.9;
access;
symbols;
locks
ashish:1.9; strict;
comment @ * @;

1.9
date 2015.03.24.12.44.39; author ashish; state Exp;
branches;
next 1.8;

1.8
date 2015.03.24.12.42.21; author ashish; state Exp;
branches;
next 1.7;

1.7
date 2015.03.24.12.38.12; author ashish; state Exp;
branches;
next 1.6;

1.6
date 2015.03.24.12.31.24; author ashish; state Exp;
branches;
next 1.5;

1.5
date 2015.03.24.12.20.10; author ashish; state Exp;
branches;
next 1.4;

1.4
date 2015.03.24.12.17.36; author ashish; state Exp;
branches;
next 1.3;

1.3
date 2015.03.24.12.14.13; author ashish; state Exp;
branches;
next 1.2;

1.2
date 2015.03.24.12.06.33; author ashish; state Exp;
branches;
next 1.1;

1.1
date 2015.03.24.12.05.45; author ashish; state Exp;
branches;
next ;

desc
@this is the programme for communication using threads and messagqueue
@

1.9
log
@now the req client will rcv the result using msgrcv(),and final result will be displayed
in similar manner the more client for different operations would be made
@
text

@
1.8
log
@now the proc will write the result in the server using write(),
now the server will read the result using read(),
and will send th result to the req client using msgsnd() func
@
text
@a59 1

d61 1
a61 1
@

1.7
log
@now doing the execl to access the process which will take out the result
in the process the data wiill be received using msgrcv(),now the further calculation will be depending upon the type of operator
@
text
@d60 1
@

1.6
log
@now creating a pipe which will return two file descripters one for read and one for write
now doing a fork(),which will creat a child and parent.
now we will write the the data using the write fd of pipe to the client which will do the further calculation
@
text
@d53 1
a53 2

@

1.5
log
@declaring a structure to access the operator and operands on which the calculation will be ddone
now reciving the req from first client using msgrcv(),which will access using the id return by msgget,creted for sending and receiving the requests
@
text
@d53 2
a54 1

@

1.4
log
@now,giving the defination of thrd(),
creating the two mesgques,one for sending and reciving the result,and second for the reciving and sending the result
where the both will returns the unique id
@
text
@a18 1

@

1.3
log
@now,declaring the variable,thd,thd_id of prototype pthread_t
now creating a thread using pthread_creat(),where it will give a unique thread id
we have to creat multi,thrd so,,,thrd(),should be provided with a loop
@
text
@a2 1

@

1.2
log
@including the all header file needed
declaring a function for creating a thread
@
text
@d3 1
@

1.1
log
@Initial revision
@
text
@a1 1

@

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

Implemented system call to invoke other processes,which will compile & execute another program respectively…

CS file: systemcall.c,v
Working file: systemcall.c
head:
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 0
description:
in the program,another program is invoked through a program through system call
the other program will  convert lower case characters to upper case & give output
=============================================================================

Posted in Uncategorized | Leave a comment

Successfully Implemented the inter-communication between 3 client , server and 3 processing-side by using pipes.

RCS file: header_server2.h,v
Working file: header_server2.h
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
include 3 library <stdio.h> , <stdlib.h>
and <unistd.h>
create a function invoke_clients() to invoke the
3 clients simultaneously but actually it's a sequential process.
given the prototype for read_clients() and pass
the two argument one is int which is arrof pipe astruct display * for
reading the request from clients to server.
also include the defination of struct display in
header file. 3 datatype one for char opt and two int oper1 and
opern2.
now introduce processing_results() and pass two
arguments. new arr1* for creating new pipe and struct display *.
----------------------------
revision 1.2	locked by: root;
date: 2015/03/18 11:36:49;  author: root; 
state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/03/16 10:26:29;  author: root; 
state: Exp;
Initial revision
RCS file: new_server.c,v
Working file: new_server.c
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
we create the *arr and provide the space for
read and write file descriptor means malloc * 6. 3 pipes we create
for 3 clients.
call the invoke_clients() and pass the address
of arr as argument.
declare **ptr and starting address store int ptr
and provide space with malloc.
store the 3 strings in 2D array.
create the pipes for 3 clients.
NOw, fork() is used to create duplicate copy or
new process .
in new process, we use execl() to replace new
process created by fork() with arguement we pass. And we also pass
two argument more read and write file discriptor but before passing
we converted it into string because execl() argument are in const
char *.
sprintf is used to convert int into char.
after this we read the request from client on
server.
then write the request to processing_results
pipes.
now, we created a processing_results() to
process the invoke_clients().
In processing_results() fumction we pass the
arr1 of 6 to create the 3 pipes.
declare the **p and provide space to store the
strings.
create the 3 pipes through for loop.
Now, fork() is used to create a new process. 
In child(new) process, we use execl() function
to replace the current process i.e new process. with arugment we used
in execl and also pass read and write file descriptor in char type
using sprintf.
----------------------------
revision 1.2	locked by: root;
date: 2015/03/18 11:36:54;  author: root; 
state: Exp;  lines: +18 -4
*** empty log message ***
----------------------------
revision 1.1
date: 2015/03/16 11:05:43;  author: root; 
state: Exp;
Initial revision


RCS file: client_sum.c,v
Working file: client_sum.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
read the file disp through main argument.
convert it into integer by using atoi.
and then write it into pipe.
----------------------------
revision 1.1	locked by: root;
date: 2015/03/16 13:39:29;  author: root; 
state: Exp;
Initial revision
=============================================================================

RCS file: client_sub.c,v
Working file: client_sub.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
we read the argument through main.
convert it into interger by using atoi before
using it into read and write function.
use struct display a object and using this 'a'
object we store the opt, opern1 and opern2.
and then write the result sub into pipe.
----------------------------
revision 1.1	locked by: root;
date: 2015/03/16 13:05:44;  author: root; 
state: Exp;
Initial revision
=============================================================================

RCS file: client_mul.c,v
Working file: client_mul.c
head: 1.1
branch:
locks: strict
	root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;	selected revisions: 1
description:
same as above
----------------------------
revision 1.1	locked by: root;
date: 2015/03/16 13:33:06;  author: root; 
state: Exp;




RCS file: processing_sum.c,v
Working file: processing_sum.c
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
read the rd and wd file descriptor from server
through argv argument.
convert argv[1] and argv[2] to rfd and wfd
integer.
read the content and print the content in
processing_sum file.
then write the result on the server pipe
----------------------------
revision 1.2	locked by: root;
date: 2015/03/18 11:36:58;  author: root; 
state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/03/06 08:21:16;  author: root; 
state: Exp;
Initial revision
=============================================================================

RCS file: processing_sub.c,v
Working file: processing_sub.c
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
read write file discriptor is taken by main
argument
convert it into integer rfd and wfd.
by using atoi.
read the struct display through address and
print the opt, opern1, opern2.
and write the subtraction result into the
server-processing pipe.
----------------------------
revision 1.2	locked by: root;
date: 2015/03/18 11:36:59;  author: root; 
state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/03/17 15:02:50;  author: root; 
state: Exp;
Initial revision
=============================================================================

RCS file: processing_mul.c,v
Working file: processing_mul.c
head: 1.2
branch:
locks: strict
	root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;	selected revisions: 2
description:
same as subtraction just changed the operator
and names and then write the result into pipe.
----------------------------
revision 1.2	locked by: root;
date: 2015/03/18 11:37:00;  author: root; 
state: Exp;  lines: +1 -1
*** empty log message ***
----------------------------
revision 1.1
date: 2015/03/17 15:48:15;  author: root; 
state: Exp;
Initial revision
=============================================================================
Posted in Project 03: Client Server Communication using Linux and IPC | Tagged , , , | Leave a comment

binarysearch using pointers

#include<stdio.h>
2 #include<stdlib.h>
3 int input(int,int *);
4 int search(int *,int,int);
5 int main()
6 {
7
8         int size=10;
9         int * ptr;
10         int i,c,s,key;
11         ptr=(int*)malloc(sizeof(int)*size);
12         c=input(size,ptr);
13         printf(“\n matrix printed are:”);
14         for(i=0;i<size;i++)
15         {
16                 printf(“elements are :%d\n”,*(ptr+i));
17         }
18          printf(“\n enter the element to be searched\n”);
19          scanf(“%d”,&key);
20         s=search(ptr,size,key);
21         printf(“key is %d”,s);
22 return 0;
23 }
24 int input(int size,int *ptr)
25 {
26 int i;
27 printf(“\n enter the matrix”);
28         for(i=0;i<size;i++)
29         {
30                 scanf(“%d”,&(*(ptr+i)));
31         }
32 }
33 int search(int *ptr,int size,int key)
int search(int *ptr,int size,int key)
34 {
35          int l=0,h=size-1,m;
36          while(l<=h)
37          {
38                 m=(l+h)/2;
39                 if(key==*(ptr+m))
40                 {
41                         printf(“element is found at %d element is %d”,m+1,key);
42                         break;
43                 }
44                 else if(key>*(ptr+m))
45                 {
46                         l=m+1;
47                 }
48                 else if(key< *(ptr+m))
49                 {
50                         h=m-1;
51                 }
52                 if(l>h)
53                 {
54                         printf(“element not found”);
55                         break;
56                 }
57         }
58         return key;
59 }

Posted in Data Structures with C | Leave a comment

Swaping of two number without using third variable.

#include<stdio.h>

int main()

{

int a,b;

printf(“enter the value of a &b”);

scanf(“%d %d”,&a,&b);

printf(“value of a=%d & b=%d\n”,a ,b);

a=a+b;

b=a-b;

a=a-b;

printf(“after swaping a=%d &b=%d\n”, a,b);

return 0;

}

Posted in Uncategorized | Leave a comment

multiply array

RCS file: mularray.c,v
Working file: mularray.c
head: 1.2
branch:
locks: strict
jyotisingh: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
input matrix a
input matrix b
logic for multiplication
print matrix
—————————-
revision 1.2    locked by: jyotisingh;
date: 2015/03/03 16:27:36;  author: jyotisingh;  state: Exp;  lines: +1 -1
modification
—————————-
revision 1.1
date: 2015/03/03 16:24:42;  author: jyotisingh;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment