EmbLogic's Blog

masterarray

masterarray created sucessfully

Posted in Uncategorized | Leave a comment

ipc

RCS file: server.c,v
Working file: 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:
make the server for a requesting client
—————————-
revision 1.2 locked by: root;
date: 2014/03/22 06:44:10; author: root; state: Exp; lines: +17 -4
data recieved in client
—————————-
revision 1.1
date: 2014/03/21 07:42:00; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

ipc

RCS file: server.c,v
Working file: 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:
make the server for a requesting client
—————————-
revision 1.2 locked by: root;
date: 2014/03/22 06:44:10; author: root; state: Exp; lines: +17 -4
data recieved in client
—————————-
revision 1.1
date: 2014/03/21 07:42:00; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

linklist

In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
Singly-linked-list.svg
A linked list whose nodes contain two fields: an integer value and a link to the next node. The last node is linked to a terminator used to signify the end of the list.

Linked lists are among the simplest and most common data structures. They can be used to implement several other common abstract data types, including lists (the abstract data type), stacks, queues, associative arrays, and S-expressions, though it is not uncommon to implement the other data structures directly without using a list as the basis of implementation.

Posted in Uncategorized | Leave a comment

functions and command line arguments.

Functions :
Functions are easy to use; they allow complicated programs to be parcelled up into small blocks, each of which is easier to write, read, and maintain. We have already encountered the function main and made use of I/O and mathematical routines from the standard libraries. Now let’s look at some other library functions, and how to write and use our own.

Calling a Function:

The call to a function in C simply entails referencing its name with the appropriate arguments. The C compiler checks for compatibility between the arguments in the calling sequence and the definition of the function.

Library functions are generally not available to us in source form. Argument type checking is accomplished through the use of header files (like stdio.h) which contain all the necessary information. For example, as we saw earlier, in order to use the standard mathematical library you must include math.h via the statement

Command-line arguments:

It is standard practice in UNIX for information to be passed from the command line directly into a program through the use of one or more command-line arguments, or switches. Switches are typically used to modify the behavior of a program, or to set the values of some internal parameters. You have already encountered several of these–for example, the “ls” command lists the files in your current directory, but when the switch -l is added, “ls -l” produces a so-called “long” listing instead. Similarly, “ls -l -a” produces a long listing, including “hidden” files, the command “tail -20″ prints out the last 20 lines of a file (instead of the default 10), and so on.

Conceptually, switches behave very much like arguments to functions within C, and they are passed to a C program from the operating system in precisely the same way as arguments are passed between functions. Up to now, the main() statements in our programs have had nothing between the parentheses. However, UNIX actually makes available to the program (whether the programmer chooses to use the information or not) two arguments to main: an array of character strings, conventionally called argv, and an integer, usually called argc, which specifies the number of strings in that array. The full statement of the first line of the program is

main(int argc, char** argv)

(The syntax char** argv declares argv to be a pointer to a pointer to a character, that is, a pointer to a character array (a character string)–in other words, an array of character strings. You could also write this as char* argv[]. Don’t worry too much about the details of the syntax, however–the use of the array will be made clearer below.)

Posted in Uncategorized | Leave a comment

program of linked list

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

1.1
date 2014.03.25.09.08.55; author Emblogic; state Exp;
branches;
next ;

desc
@this is a program of linked list
to insert the node at beginning,position and end
to delete the node at begining,position,end
to dispay the linked list
@

1.1
log
@Initial revision
@
text
@#include
#include
struct node
{
int data;
struct node *next;
};
struct node * create_node();
struct node * insert_node(struct node *);
struct node * delete_node(struct node *);
void display(struct node *);
struct node * insert_beg(struct node *);
struct node * insert_pos(struct node *);
struct node * insert_end(struct node *);
struct node * delete_beg(struct node *);
struct node * delete_pos(struct node *);
struct node * delete_end(struct node *);

int main()
{
struct node *start;
int ch;
do
{
printf(“1: create_node\n”);
printf(“2: insert_node\n”);
printf(“3: delete_node\n”);
printf(“4: display\n”);
printf(“5: exit\n”);
printf(“enter your choice\n”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
start=create_node();
break;
case 2:
start=insert_node(start);
break;
case 3:
start=delete_node(start);
break;
case 4:
display(start);
break;
case 5:
break;
}

}while(ch != 5);

}
struct node * create_node()
{
struct node *start;
start=malloc(sizeof(struct node));
printf(” enter data\n”);
scanf(“%d”,&start->data);
start->next= NULL;
return start;
}

struct node * insert_node(struct node *start)
{
int ch;
printf(“1: insert at begining\n”);
printf(“2: insert at position\n”);
printf(“3: insert at end\n”);
printf(“enter your choice\n”);
scanf(“%d”,&ch);

switch(ch)
{
case 1:
start=insert_beg(start);
break;
case 2:
start=insert_pos(start);
break;
case 3:
start=insert_end(start);
break;
}
return start;

}

struct node * delete_node(struct node *start)
{
int ch;
printf(“1: delete at begining\n”);
printf(“2: delete at position\n”);
printf(“3: delete at end\n”);
printf(“enter your choice\n”);
scanf(“%d”,&ch);

switch(ch)
{
case 1:
start=delete_beg(start);
break;
case 2:
start=delete_pos(start);
break;
case 3:
start=delete_end(start);
break;
}
return start;

}

void display(struct node *start)
{
struct node *temp;
temp=start;
while(temp != NULL)
{
printf(“the data is %d”,temp->data);
temp=temp->next;
}
}

struct node * insert_beg(struct node *start)
{
struct node *temp;
temp=start;
start=create_node();
start->next=temp;
return start;
}
struct node * insert_pos(struct node *start)
{
struct node *temp, *new;
int n,i;
temp=start;
printf(“enter the position\n”);
scanf(“%d”,&n);
for(i=0; i next;
}
new=create_node();
new->next=temp->next;
temp->next=new;
return start;
}
struct node * insert_end(struct node *start)
{
struct node *temp,*new;
temp=start;
while(temp != NULL)
{
temp=temp->next;
}
new=create_node();
temp->next=new;
new->next= NULL;
return start;
}

struct node * delete_beg(struct node *start)
{
struct node *temp;
temp= start;
start=start->next;
free(temp);
return start;
}
struct node * delete_pos(struct node *start)
{
struct node *temp, *prev;
int n,i;
temp=start;
printf(“enter the position\n”);
scanf(“%d”,&n);
for(i=0; i next;
}
prev->next=temp->next;
free(temp);
return start;
}
struct node * delete_end(struct node *start)
{
struct node *temp,*prev;
temp=start;
while(temp->next != NULL)
{
prev=temp;
temp=temp->next;
}
free(temp);
prev->next= NULL;
return start;
}
@

Posted in Uncategorized | Leave a comment

ipc using pipe

head 1.2;
access;
symbols;
locks
arjun:1.2; strict;
comment @ * @;

1.2
date 2014.03.25.08.06.10; author arjun; state Exp;
branches;
next 1.1;

1.1
date 2014.03.25.05.16.16; author arjun; state Exp;
branches;
next ;

desc
@we are using 2 pipe for requesting client and same for processing client
but not use switch case in server.
@

1.2
log
@we are using switch case in server to find out the operator.
@
text
@#include
#include
int main()
{
int i,pfd1[2],pfd2[2],pfd3[2],pfd4[2],pid1,pid2,pid3,pid4,pid5,pid6,ret1r,ret1w,ret2r,ret2w,ret3r,ret3w,ret4r,ret4w,ret5r,ret5w,ret6r,ret6w,ret1,ret2,ret3,ret4,buf1[4],buf2[4],buf3[4],buf4[4],addres,subres,mulres,ch;
char a[4],b[4],c[4],d[4],e[4],f[4],g[4],h[4];
ret1=pipe(pfd1);
ret2=pipe(pfd2);
ret3=pipe(pfd3);
ret4=pipe(pfd4);
sprintf(a,”%d”,pfd1[0]);
sprintf(b,”%d”,pfd1[1]);
sprintf(c,”%d”,pfd2[0]);
sprintf(d,”%d”,pfd2[1]);
sprintf(e,”%d”,pfd3[0]);
sprintf(f,”%d”,pfd3[1]);
sprintf(g,”%d”,pfd4[0]);
sprintf(h,”%d”,pfd4[1]);
pid1=fork();
if(pid1>0)
{
printf(“i am parent\n”);
ret1r=read(pfd1[0],buf1,12);

pid2=fork();
if(pid2==0)
{
printf(“i am child2\n”);
execl(“./cl2″,”arjun”,b,c,NULL);
}
else
{
ret2r=read(pfd1[0],buf2,12);
}
pid3=fork();
if(pid3==0)
{
printf(“i am child3\n”);
execl(“./cl3″,”arjun”,b,c,NULL);
}
else
{

ret3r=read(pfd1[0],buf3,12);
}
int *buff4[3]={(int*)buf1,(int*)buf2,(int*)buf3};
for(i=0;i<3;i++)
{
ch= *((int*)buff4[i]);
switch(ch)
{
case 43:
{
pid4=fork();
if(pid4==0)
{
ret4w=write(pfd3[1],buf1,12);
printf("i am pchild1\n");
execl("./pcl1","arjun",e,h,NULL);
}
else
{
ret4r=read(pfd4[0],&addres,4);
ret1w=write(pfd2[1],&addres,4);
}
}
break;
case 45:
{
pid5=fork();
if(pid5==0)
{
ret5w=write(pfd3[1],buf2,12);
printf("i am pchild2\n");
execl("./pcl2","arjun",e,h,NULL);
}
else
{
ret5r=read(pfd4[0],&subres,4);
ret2w=write(pfd2[1],&subres,4);
}
}
break;
default :
{
pid6=fork();
if(pid6==0)
{
ret6w=write(pfd3[1],buf2,12);
printf("i am pchild3\n");
execl("./pcl3","arjun",e,h,NULL);
}
else
{
ret6r=read(pfd4[0],&subres,4);
ret3w=write(pfd2[1],&subres,4);
}
}
break;
}
}

}
else
{
printf("i am child1\n");
execl("./cl1","arjun",b,c,NULL);
}
}
@

1.1
log
@Initial revision
@
text
@d5 1
a5 1
int i,pfd1[2],pfd2[2],pfd3[2],pfd4[2],pid1,pid2,pid3,pid4,pid5,pid6,ret1r,ret1w,ret2r,ret2w,ret3r,ret3w,ret4r,ret4w,ret5r,ret5w,ret6r,ret6w,ret1,ret2,ret3,ret4,buf1[4],buf2[4],buf3[4],buf4[4],addres,subres,mulres;
d48 2
a49 3

pid4=fork();
if(pid4==0)
d51 52
a102 3
ret4w=write(pfd3[1],buf1,12);
printf("i am pchild1\n");
execl("./pcl1","arjun",e,h,NULL);
a103 32
else
{
ret4r=read(pfd4[0],&addres,4);
ret1w=write(pfd2[1],&addres,4);
}

pid5=fork();
if(pid5==0)
{
ret5w=write(pfd3[1],buf2,12);
printf("i am pchild2\n");
execl("./pcl2","arjun",e,h,NULL);
}
else
{
ret5r=read(pfd4[0],&subres,4);
ret2w=write(pfd2[1],&subres,4);
}
pid6=fork();
if(pid6==0)
{
ret6w=write(pfd3[1],buf2,12);
printf("i am pchild3\n");
execl("./pcl3","arjun",e,h,NULL);
}
else
{
ret6r=read(pfd4[0],&subres,4);
ret3w=write(pfd2[1],&subres,4);
}

@

Posted in Uncategorized | Leave a comment

ipc server using pipe

head 1.2;
access;
symbols;
locks
poonam:1.2; strict;
comment @ * @;

1.2
date 2014.03.25.05.06.08; author poonam; state Exp;
branches;
next 1.1;

1.1
date 2014.03.25.02.12.49; author poonam; state Exp;
branches;
next ;

desc
@implemented server with three requesting client and three processing client bt result is not perfect for each requesting client.
@

1.2
log
@used switch to run different processing clients.
@
text
@#include”header.h”
int main()
{
int i,pipe1,pipe2,pipe3,pipe4,data_r1,data_r2,data_r3,data_add,data_sub,data_mul,plus[2],plus_r,plus_w,minus[2],minus_r,minus_w,mul[2],mul_r,mul_w;
int pid1,pid2,pid3,pid4,pid5,pid6,ch;
int fd_com_req[2], fd_com_res[2],fd_com_preq[2],fd_com_pres[2];
char a[4],b[4],c[4],d[4],e[4],f[4],g[4],h[4];
int buf_client1_r[3], buf_client2_r[3], buf_client3_r[3];
pipe1=pipe(fd_com_req);
pipe2=pipe(fd_com_res);
pipe3=pipe(fd_com_preq);
pipe4=pipe(fd_com_pres);
sprintf(a,”%d”,fd_com_req[1]);
sprintf(b,”%d”,fd_com_req[0]);
sprintf(c,”%d”,fd_com_res[1]);
sprintf(d,”%d”,fd_com_res[0]);
sprintf(e,”%d”,fd_com_preq[1]);
sprintf(f,”%d”,fd_com_preq[0]);
sprintf(g,”%d”,fd_com_pres[1]);
sprintf(h,”%d”,fd_com_pres[0]);
printf(“this is server\n”);
pid1=fork();
if(pid1!=0)
{
data_r1=read(fd_com_req[0],buf_client1_r,12);
for(i=0;i<3;i++)
printf("client1[%d]=%d\n",i,buf_client1_r[i]);
pid2=fork();
if(pid2!=0)
{
data_r2=read(fd_com_req[0],buf_client2_r,12);
for(i=0;i<3;i++)
printf("client2[%d]=%d\n",i,buf_client2_r[i]);
pid3=fork();
if(pid3!=0)
{
data_r3=read(fd_com_req[0],buf_client3_r,12);
for(i=0;i<3;i++)
printf("client3[%d]=%d\n",i,buf_client3_r[i]);
int *server_buf[3] = {(int*) (buf_client1_r+0), (int*)(buf_client2_r+0),(int*)(buf_client3_r+0)};
for(i=0;i<3;i++)
{
printf("server buf %d \n",*((int*)server_buf[i]));
ch = *((int*)server_buf[i]);
switch(ch)
{
case 43: printf("add \n");
pid4=fork();
if(pid4!=0)
{
plus_r = read(fd_com_pres[0],plus,8);
printf("plus result is =%d\n",plus[1]);
plus_w = write(fd_com_res[1],plus,8);
}
else
{

data_add = write(fd_com_preq[1],buf_client1_r,12);
execl("./add","add",f,g,NULL);
}
break;

case 45: pid5=fork();
if(pid5!=0)
{
minus_r = read(fd_com_pres[0],minus,8);
printf("minus result is =%d\n",minus[1]);
minus_w = write(fd_com_res[1],minus,8);
}
else
{

data_sub = write(fd_com_preq[1],buf_client2_r,12);
execl("./sub","sub",f,g,NULL);
}
break;
case 42: pid6=fork();
if(pid6!=0)
{
mul_r = read(fd_com_pres[0],mul,8);
printf("mul result is =%d\n",mul[1]);
mul_w = write(fd_com_res[1],mul,8);
}
else
{

data_mul = write(fd_com_preq[1],buf_client3_r,12);
execl("./mul","mul",f,g,NULL);
}
break;
}
/* else
{

data_sub = write(fd_com_preq[1],buf_client2_r,12);
execl("./sub","sub",f,g,NULL);
}

}
else
{

data_add = write(fd_com_preq[1],buf_client1_r,12);
execl("./add","add",f,g,NULL);
}*/
}
}

else
{

execl("./cl3","client3",a,d,NULL);
}
}
else
{
execl("./cl2","client2",a,d,NULL);
}

}
else
{
execl("./cl1","client1",a,d,NULL);
}
}

@

1.1
log
@Initial revision
@
text
@d5 1
a5 1
int pid1,pid2,pid3,pid4,pid5,pid6;
d40 47
a86 22
//printf("clients req are \n");
pid4=fork();
if(pid4!=0)
{
plus_r = read(fd_com_pres[0],plus,8);
printf("plus result is =%d\n",plus[1]);
plus_w = write(fd_com_res[1],plus,8);
pid5=fork();
if(pid5!=0)
{
minus_r = read(fd_com_pres[0],minus,8);
printf("minus result is =%d\n",minus[1]);
minus_w = write(fd_com_res[1],minus,8);
pid6=fork();
if(pid6!=0)
{
mul_r = read(fd_com_pres[0],mul,8);
printf("mul result is =%d\n",mul[1]);
mul_w = write(fd_com_res[1],mul,8);
}
else
{
d90 2
a91 1
}
d93 1
a93 1
else
d106 2
a107 1
}
d109 1
@

Posted in Uncategorized | Leave a comment

Semaphore

Its a synchronization mechanism in which one process can access shared resource at one time and other processes are in a wait stage.Its used in synchronizing multiple processes.The processes are in a queue,when semaphore increments or when its greater than zero then all the process pops out of the queue and only one process enter the critical region,when a process enters the critical region it decrements semaphore and after process completion it exits increments and exits the semaphore.The increment operation is known as a “signal” and decrement operation is “wait”.

To make a semaphore,its variable should be greater the zero.To initialize a Semaphore 3 function definition are used :

1. kernel key=segmet(user key,no. of semaphores,666|IPC_CREAT);

2. semctl(kernel key,index,command,…(optional));

3. semop(kernel key,struct sembuf*sops,size of sops);

 

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

linklist

RCS file: linklist.c,v
Working file: linklist.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
implement linklist using menu options
—————————-
revision 1.1 locked by: root;
date: 2011/04/21 03:43:26; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Arrays

An array is a collection of data items, all of the same type, accessed using a common name.
A one-dimensional array is like a list; A two dimensional array is like a table; The C language places no limits on the number of dimensions in an array, though specific implementations may.
Some texts refer to one-dimensional arrays as vectors, two-dimensional arrays as matrices, and use the general term arrays when the number of dimensions is unspecified or unimportant.

Declaring Arrays:

Array variables are declared identically to variables of their data type, except that the variable name is followed by one pair of square [ ] brackets for each dimension of the array.
Uninitialized arrays must have the dimensions of their rows, columns, etc. listed within the square brackets.
Dimensions used when declaring arrays in C must be positive integral constants or constant expressions. ( Space is allocated only once, at the time the array is declared. The array does NOT change sizes later if the variable used to declare it changes. )

Examples:

int i, j, intArray[ 10 ], number;
float floatArray[ 1000 ];
int tableArray[ 3 ][ 5 ]; /* 3 rows by 5 columns

Initializing Arrays:

Arrays may be initialized when they are declared, just as any other variables.
Place the initialization data in curly {} braces following the equals sign. Note the use of commas in the examples below.
An array may be partially initialized, by providing fewer data items than the size of the array. The remaining array elements will be automatically initialized to zero.
If an array is to be completely initialized, the dimension of the array is not required. The compiler will automatically size the array to fit the initialized data.
Examples:

int i = 5, intArray[ 6 ] = { 1, 2, 3, 4, 5, 6 }, k;
float sum = 0.0f, floatArray[ 100 ] = { 1.0f, 5.0f, 20.0f };
double piFractions[ ] = { 3.141592654, 1.570796327, 0.785398163 };

Designated assignment:
This method can be mixed in with traditional iniitalization
For example:

int numbers[ 100 ] = { 1, 2, 3, [10] = 10, 11, 12, [60] = 50, [42] = 420 };

In this example,the first three elements are initialized to 1, 2, and 3 respectively.
Then element 10 ( the 11th element ) is initialized to 10
The next two elements ( 12th and 13th ) are initialized to 11 and 12 respectively.
Element number 60 ( the 61st ) is initialized to 50, and number 42 ( the 43rd ) to 420.
( Note that the designated initializers do not need to appear in order. )
As with traditional methods, all uninitialized values are set to zero.
If the size of the array is not given, then the largest initialized position determines the size of the array.

Using Arrays:

Elements of an array are accessed by specifying the index ( offset ) of the desired element within square [ ] brackets after the array name.
Array subscripts must be of integer type. ( int, long int, char, etc.
Arrays are commonly used in conjunction with loops, in order to perform the same calculations on all ( or some part ) of the data items in the array.

Sample Programs Using 1-D Arrays

The first sample program uses loops and arrays to calculate the first twenty Fibonacci numbers. Fibonacci numbers are used to determine the sample points used in certain optimization methods.

/* Program to calculate the first 20 Fibonacci numbers. */

#include
#include

int main( void ) {

int i, fibonacci[ 20 ];

fibonacci[ 0 ] = 0;
fibonacci[ 1 ] = 1;

for( i = 2; i < 20; i++ )
fibonacci[ i ] = fibonacci[ i - 2 ] + fibonacci[ i - 1 ];

for( i = 0; i < 20; i++ )
printf( "Fibonacci[ %d ] = %f\n", i, fibonacci[ i ] );

} /* End of sample program to calculate Fibonacci numbers */

Exercise: What is the output of the following program:

/* Sample Program Using Arrays */

#include
#include

int main( void ) {

int numbers[ 10 ];
int i, index = 2;

for( i = 0; i < 10; i++ )
numbers[ i ] = i * 10;

numbers[ 8 ] = 25;
numbers[ 5 ] = numbers[ 9 ] / 3;
numbers[ 4 ] += numbers[ 2 ] / numbers[ 1 ];
numbers[ index ] = 5;
++numbers[ index ];
numbers[ numbers[ index++ ] ] = 100;
numbers[ index ] = numbers[ numbers[ index + 1 ] / 7 ]–;

for( index = 0; index < 10; index++ )
printf( "numbers[ %d ] = %d\n" index, numbers[ index ] );

} /* End of second sample program

Posted in Uncategorized | Leave a comment

enter a string and compress with the help of masterarray

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

1.1
date    2014.03.23.21.53.35;    author root;    state Exp;
branches;
next    ;

desc
@master array with compression
@

1.1
log
@Initial revision
@
text
@#include<stdio.h>
#include<string.h>
#include<fcntl.h>
int main()
{
int i=0,j,len,maslen=1,fd,ret;
char arr[100]={0};
char masterarr[25]={0};
fd=open(“add.c”,O_RDONLY);
if(fd<0)
{
perror(“open”);
goto OUT;
}
printf(“fd=%d\n”,fd);

ret=read(fd,&arr[i],1);
for(i=1;ret>0;i++)
{
ret=read(fd,&arr[i],1);
printf(“\nret=%d,data is %c\n”,ret,arr[i]);
}

len=strlen(arr);
unsigned int ch1,ch2,comp,fd1;
for(i=0;i<len;i++)
{
for(j=0;j<maslen;j++)
{
if(j+1==maslen)
{
masterarr[j]=arr[i];
maslen++;
break;
}
else
{
if(masterarr[j]==arr[i])
break;
}
}
}
printf(“masterarr=%s\n”,masterarr);
fd1=open(“compress”,O_CREAT|O_RDWR,777);
if(fd<0)
{
perror(“open”);
goto OUT;
}

for(i=0;i<len;i++)
{
for(j=0;j<maslen;j++)
{
if(masterarr[j]==arr[i])
{
ch1=j;
break;
}
}
i++;
for(j=0;j<maslen;j++)
{
if(masterarr[j]==arr[i])
{
ch2=j;
break;
}
}
printf(“value in ch1 %d\n and ch2 %d\n”,ch1,ch2);

ch2=ch2<<4;
comp=ch1|ch2;
printf(“comp=%d”,comp);
write(fd1,&comp,1);
}
return 0;
OUT:
return-1;
}

@

Posted in Uncategorized | Leave a comment

Output of following program?

int main()
{
static int i=5;
if(–i){
main();
printf(“%d “,i);
}
}

answer is 0000

Posted in Uncategorized | Leave a comment

create linklist and display the data

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

1.1
date 2014.03.23.22.24.26; author root; state Exp;
branches;
next ;

desc
@create linklist .
@

1.1
log
@Initial revision
@
text
@#include
#include
#include
struct node
{
int roll;
char name[20];
struct node *next;
};
void creat_node(struct node * temp)
{
struct node *start;
temp->next=malloc(sizeof(struct node));
temp=temp->next;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
temp->next=NULL;

}
void display_node(struct node *temp)
{
while(temp!=NULL)
{
printf(“roll is %d\n”,temp->roll);
printf(“name is %s\n”,temp->name);
temp=temp->next;
}
}
int main()
{
int i,n;

struct node *start,*temp;
start=malloc(sizeof(struct node));
temp=start;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
printf(“enter the number of no. of node\n”);
scanf(“%d”,&n);
temp->next=NULL;
creat_node(temp);

for(i=0;inext;
}

display_node(start);
{
display_node(start);
}

}
@

Posted in Uncategorized | Leave a comment

create linklist and display the data

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

1.1
date    2014.03.23.22.24.26;    author root;    state Exp;
branches;
next    ;

desc
@create linklist .
@

1.1
log
@Initial revision
@
text
@#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
int roll;
char name[20];
struct node *next;
};
void creat_node(struct node * temp)
{
struct node *start;
temp->next=malloc(sizeof(struct node));
temp=temp->next;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
temp->next=NULL;

}
void display_node(struct node *temp)
{
while(temp!=NULL)
{
printf(“roll is %d\n”,temp->roll);
printf(“name is %s\n”,temp->name);
temp=temp->next;
}
}
int main()
{
int i,n;

struct node *start,*temp;
start=malloc(sizeof(struct node));
temp=start;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
printf(“enter the number of no. of node\n”);
scanf(“%d”,&n);
temp->next=NULL;
creat_node(temp);

for(i=0;i<n;i++)
{
creat_node(temp);
temp=temp->next;
}

display_node(start);
{
display_node(start);
}

}
@

Posted in Uncategorized | Leave a comment