Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Program will demonstrate the insertion of an element at desired position

/* Inserting an element into contiguous list (Linear Array) at particular position */

/* contiguous_list.C */

# include

/* definition of linear list */

typedefstruct

{

}list;

int data[10];

int count;

/*prototypes of functions */ void insert(list *, int, int); void create(list *);

 

void traverse(list *);

/* Definition of the insert funtion */

void insert(list *start, int position, int element)

{

int temp = start->count;

while( temp >= position)

{

start->data[temp+1] = start->data[temp];

temp --;

}

start->data[position] = element;

start->count++ ;

}

/* definition of the create function to READ data values in the list */

void create(list *start)

{

inti=0, test=1;

while(test)

{

fflush(stdin);

printf("\n input value for: %d:(zero to come out) ", i);

scanf("%d", &start->data[i]);

if(start->data[i] == 0)

test=0;

else

}

i++;

start->count=i;

}

/* OUTPUT FUNCTION TO PRINT ON THE CONSOLE */

void traverse(list *start)

{

inti;

for(i = 0; i< start->count; i++)

{

printf("\n Value at the position: %d: %d ", i, start->data[i]);

}

}

/* main function */

void main( )

{

int position, element;

list l;

create(&l);

printf("\n Entered list as:\n");

fflush(stdin);

traverse(&l);

fflush(stdin);

printf("\n input the position where youdesire to insert new item:");

scanf("%d", &position);

fflush(stdin);

printf("\n input value for desired position:");

scanf("%d", &element); insert(&l, position, element); traverse(&l);

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9619376

Have any Question?


Related Questions in Computer Engineering

The switch statementhere is the question in its entirety

The switch statement Here is the question in its entirety, but the actual problem is at the end. I just felt that I would give an overview of what I am asking. The program has to be in c++ (.cpp) and must compile as such ...

What are some analysis and crime investigative methods that

What are some analysis and crime investigative methods that could be used in identifying gangs and/or gang activities?

Need references for information for the following dealing

Need references for information for the following dealing with CSMS (Consolidated Sales and Marketing System Project) Produce a narrative which describes the added error-handling pathways that includes: an overview of th ...

You have 2 tasks to createer-modeling in ms visio simple

You have 2 tasks to createER-Modeling in MS visio. Simple jab for the database expert that would take him 30 min to finish. My requirement not only for the expert to get the task done. I need to do it myself. Then he cor ...

A small factory produces two types of toys trucks and

A small factory produces two types of toys: trucks and bicycles. In the manufacturing process two machines are used: the piece maker and the assembler. It takes 2 hours to make the pieces of the bicycles and 1 hour for t ...

When using todays digital cameras file sizes are often

When using today's digital cameras file sizes are often saved in a format that is well over 1 Megabyte. This may be great for high definition photo reproductions but is a disaster for uploading to the web. Images on your ...

Question discuss in 500 words how you would advise your

Question: Discuss, in 500 words, how you would advise your current employer to use encryption to reduce the vulnerabilities of their data at rest, in use, and in transit (or in motion). Identify at what points you think ...

Systems analysis and design project 11 can you answer these

Systems analysis and design project 11: can you answer these 3 questions please 1. Design a generic test plan that describes the testing for an imaginary system. 2. Design a generic post-implementation evaluation form. T ...

Command to mail only the process id of running java program

Command to mail only the process ID of running Java program test to the email address (single line Unix)

When talking about economics and the history of it for the

When talking about Economics and the history of it. For the past recessions the U.S. has had, do we look at it mostly on the loan side of the banks or what causes most recessions?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As