EmbLogic's Blog

C program for sorting an array in asscending order and binary searching

#include
int main()
{
int i,j,a[100],b,n,c,low,mid,high;
printf(“How many no. you want to add in an array:”);
scanf(“%d”,&n);
printf(“Enter element of array:\n”);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;ja[j])
{
b=a[i];
a[i]=a[j];
a[j]=b;

}
}
}
printf(“Array after sorting is:\n”);
for(i=0;ia[mid])
{
low=mid+1;
high=n-1;
}
else if(chigh)
{
printf(“%d is not found\n”,c);
break;#include
int main()
{
int i,j,a[100],b,n,c,low,mid,high;
printf(“How many no. you want to add in an array:”);
scanf(“%d”,&n);
printf(“Enter element of array:\n”);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;ja[j])
{
b=a[i];
a[i]=a[j];
a[j]=b;

}
}
}
printf(“Array after sorting is:\n”);
for(i=0;ia[mid])
{
low=mid+1;
high=n-1;
}
else if(c
high)
{
printf(“%d is not found\n”,c);
break;
}
}
}
}
}
}

Posted in Data Structures with C | Leave a comment

C program to merge two aaray

#include
int main()
{
int a[100],b[100],i,j,k,l,c[100],m,n,o,x,y;
printf(“How many no. do you want to add in array a[100]:”);
scanf(“%d”,&n);
printf(“Enter element of first array:\n”);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("How many no. do you want to add in array b[100]:");
scanf("%d",&o);
printf("Enter element of second array:\n");
for(i=0;i<o;i++)
{
scanf("%d",&b[i]);
}
for(i=0,k=0;i<n,k<o;i++,k++)
{
for(j=i+1,l=k+1;j<n,la[j])
{
x=a[i];
a[i]=a[j];
a[j]=x;
}
if(b[k]>b[l])
{
y=b[k];
b[k]=b[l];
b[l]=y;
}
}
}
printf(“Element of array a[100] after sorting:\n”);
for(i=0;i<n;i++)
{
printf("a[%d]=%d\n",i,a[i]);
}
printf("Element of array b[100] after sorting:\n");
for(i=0;i<o;i++)
{
printf("b[%d]=%d\n",i,b[i]);
}
j=0;k=0;
for(i=0;i<n+o;i++)
{
if(j<n && k<o)
{
if(a[j]<b[k])
{
c[i]=a[j];
j++;
}
else
{
c[i]=b[k];
k++;
}
}
else if(j==n)
{
for(;i<n+o;i++)
{
c[i]=b[k];
k++;
}
}
else
{
for(;i<n+o;i++)
{
c[i]=a[j];
j++;
}
}
}
printf("merged array is:\n");
for(i=0;i<n+o;i++)
{
printf("c[%d]=%d\n",i,c[i]);
}
}

Posted in Data Structures with C | Leave a comment

Stack using array Logfile.

STACK implementation using array completed.

RCS file: stack.c,v
Working file: stack.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;     selected revisions: 4
description:
STACK MAIN PROGRAM. In initial rev 1.1 – implemented getchoice(), operation(), and declared push(),pop(),display() for testing.
—————————-
revision 1.4    locked by: root;
date: 2014/07/05 18:40:43;  author: root;  state: Exp;  lines: +5 -3
Made changes to display() to have a better display pattern for stack.
—————————-
revision 1.3
date: 2014/07/05 18:25:20;  author: root;  state: Exp;  lines: +14 -3
Implemeted POP operation on stack.
—————————-
revision 1.2
date: 2014/07/05 18:14:14;  author: root;  state: Exp;  lines: +31 -4
Implemeted PUSH and DISPLAY functions on stack.
—————————-
revision 1.1
date: 2014/07/05 17:56:15;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

C program for sorting an array in asscending order

#include<stdio.h>
int main()
{
int a[100],i,j,n,temp;
printf(“How many no. you want to add in an array:”);
scanf(“%d”,&n);
printf(“Enter element of an array:\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
printf(“Array before sorting is:\n”);
for(i=0;i<n;i++)
{
printf(“%d\n”,a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf(“Array after sorting is:\n”);
for(i=0;i<n;i++)
{
printf(“a[%d]=%d\n”,i,a[i]);
}
}

Posted in Data Structures with C | Leave a comment

FTP,TFTP & NFS server configuration..

today i configured FTP,TFTP & NFS servers……

Posted in Data Structures with C | Leave a comment

client server communication

for three client——
i’ve used common pipe for processing of data of all the client while i’ve used three different pipe between each client and server for their respective data communication.
—–server—-
RCS file: ./server.c,v
Working file: ./server.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
working for second client
created a pipe an
for communication between server and client2
—————————-
revision 1.4 locked by: root;
date: 2014/07/05 08:35:03; author: root; state: Exp; lines: +45 -7
make a new pipe for client3
recieve the data from client3 and proceed it to process 3
the process3 use the common pipe for all the three process
for sync i’ve used sleep
—————————-
revision 1.3
date: 2014/07/05 04:02:23; author: root; state: Exp; lines: +26 -5
in server for the client_2 i add a pipe between the client2 and server
by using the previous pipe which is between process1 and server
i used data communication between server and process2
to sync i used sleep as per requirement
—————————-
revision 1.2
date: 2014/07/04 18:58:33; author: root; state: Exp; lines: +7 -4
creating new pipe for process2
—————————-
revision 1.1
date: 2014/07/04 17:21:57; author: root; state: Exp;
Initial revision
=============================================================================

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

client server communication using pipe

i’ve done this program for two client —
inside this program i have to client which need two different action(operation) .the server accept the request of client by using pipe .to perform their desired operation the server again sent this data to process by using pipe.for both operation i have used single pipe for process1 and process2.after processing the sever request the process1 or process2 wrote the output in pipe which fetched by server.and sever use the respective pipe of client1 and client2 and write this output to client pipe which is then fetched by client.
to manage the sychronisation i’ve use sleep.we can also used signal for proper sync.
——server……….

RCS file: server.c,v
Working file: server.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
working for second client
created a pipe an
for communication between server and client2
—————————-
revision 1.3 locked by: root;
date: 2014/07/05 04:02:23; author: root; state: Exp; lines: +26 -5
in server for the client_2 i add a pipe between the client2 and server
by using the previous pipe which is between process1 and server
i used data communication between server and process2
to sync i used sleep as per requirement
—————————-
revision 1.2
date: 2014/07/04 18:58:33; author: root; state: Exp; lines: +7 -4
creating new pipe for process2
—————————-
revision 1.1
date: 2014/07/04 17:21:57; author: root; state: Exp;
Initial revision
=============================================================================

—-client—–

RCS file: ./client2.c,v
Working file: ./client2.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
created a client2.c function
which provides the data to server
by using pipe
and again after processing the data it receive the data from server by using same pipe
for the sync. i used sleep
as per needed
—————————-
revision 1.1 locked by: root;
date: 2014/07/05 04:06:40; author: root; state: Exp;
Initial revision
=============================================================================
——process—–

RCS file: ./process2.c,v
Working file: ./process2.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
in the process2 i used the same pipe which has been previously used
between process1 and server
in the process i perform the operation as per operator
after performing operation process2 return the result to the server
—————————-
revision 1.1 locked by: root;
date: 2014/07/05 04:08:53; author: root; state: Exp;
Initial revision
=============================================================================

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

in.linkedin.com/pub/satinder-singh/69/b56/2b1/

Satinder Singh

Posted in Uncategorized | Leave a comment

MDC 5 BIT COMPRESSION

MDC 5 BIT COMPRESSION:

RCS file: compress_5.c,v
Working file: compress_5.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
5 bit compression
—————————-
revision 1.1    locked by: root;
date: 2014/07/04 13:31:02;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

program to handle orphan process

when the parent process finish it’s execution and the child process is not finished then in this case prompt don’t come normally.the termination goes abnormal then we get the prompt.to resolve this issue we use wait()

RCS file: ./orphan_using_wait.c,v
Working file: ./orphan_using_wait.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
when the parent process complete its execution
then the child becomes orphan process
in this case our prompt don’t came automatically
to handle this we use wait() function
—————————-
revision 1.1 locked by: root;
date: 2014/07/04 13:17:35; author: root; state: Exp;
Initial revision
=============================================================================

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

MDC 4 bit decompression

RCS file: decompression.c,v
Working file: decompression.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
4 bit decompression
—————————-
revision 1.1    locked by: root;
date: 2014/06/15 17:24:08;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

MDC 4 bit compression

RCS file: nitasha.c,v
Working file: nitasha.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
4 bit compression
—————————-
revision 1.1    locked by: root;
date: 2014/06/15 15:18:02;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

program for single server client ipc

program for server:
for single server,client and process i have used one pipe for communication between server and client and another one for communication between server and process .as pipe can only used between related process thats why we need two fork() for these functionalities
——-server———-

RCS file: server.c,v
Working file: server.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 receive data from client
then read it and further it write the data into process
again it receive the processing data from process program
now sent the output to client by pipe
—————————-
revision 1.1 locked by: root;
date: 2014/07/04 12:22:14; author: root; state: Exp;
Initial revision
=============================================================================
———-client————-

RCS file: server.c,v
Working file: server.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 receive data from client
then read it and further it write the data into process
again it receive the processing data from process program
now sent the output to client by pipe
—————————-
revision 1.1 locked by: root;
date: 2014/07/04 12:22:14; author: root; state: Exp;
Initial revision
=============================================================================
———process………………

RCS file: server.c,v
Working file: server.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 receive data from client
then read it and further it write the data into process
again it receive the processing data from process program
now sent the output to client by pipe
—————————-
revision 1.1 locked by: root;
date: 2014/07/04 12:22:14; author: root; state: Exp;
Initial revision
=============================================================================

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

simple ‘calculator’ using do-while…

1#include<stdio.h>
2 #include<math.h>
3 int main()
4 { int a,b,i;
5   printf(“\n\nenter two no.s : “);
6   scanf(“%d %d”,&a,&b);
7         do
8         {
9           printf(“\nenter 1 for ‘+’ : “);
10           printf(“\nenter 2 for ‘-’ : “);
11           printf(“\nenter 3 for ‘*’ : “);
12           printf(“\nenter 4 for ‘/’ : \n”);
13
14           scanf(“%d”,&i);
15
16              switch(i)
17              {
18                      case 1: printf(“\nthe ans. is : %d\n”,a+b);
19                         break;
20                      case 2: printf(“\nthe ans. is :%d\n”,a-b);
21                         break;
22                      case 3: printf(“\nthe ans. is :%d\n”,a*b);
23                         break;
24                         case 4: printf(“\nthe ans. is :%d\n”,a/b);
25                         break;
26                 default:printf(“\nenter valid option\n”);
27              }
28
29
30         }
31
32         while(i!=0);
33 }

Posted in Data Structures with C | Leave a comment

READING OPERATION IN CHARACTER DRIVER DONE SUCCESSFULLY

RCS file: sread.c,v
Working file: sread.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 reading function to read the data from the kernel space.
—————————-
revision 1.2 locked by: root;
date: 2014/07/01 06:45:56; author: root; state: Exp; lines: +5 -15
*** empty log message ***
—————————-
revision 1.1
date: 2014/07/01 05:59:35; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment