answersLogoWhite

0


Best Answer

InsertNode(NODE **q,int num)

{

NODE *r,*temp ;

temp = *q;

r= malloc(sizeof(NODE));

r->data = num;

//if it's fisrt node to be inserted

if ( *q == NULL num < (*q)->data)

{

*q = r ;

(*q)->link=temp;

}

else

{

while(temp)

{

if ( (num > temp->data) && (num < temp->link->data ) )

{

r->link = temp->link;

temp->link = r;

return;

}

temp = temp->link;

}

r->link = NULL;

temp->link = r;

}

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

huh?

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Given a linked list of integers sorted in an ascending order and a pointer to a single node containing an integer write a C program that insert the node P in the linked list so that remains sorted?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is triple pointer?

Example: int x; -- integer int *px= &amp;x; -- pointer to integer int **ppx= &amp;px; -- pointer to pointer to integer int ***pppx= &amp;ppx; -- pointer to pointer to pointer to integer


Are pointers integers?

A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.


How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


What is the purpose of the dereference operator when used with a pointer variable?

Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array


How would you read int const p?

int const *p declares a 'p' pointer, that points to a constant integer

Related questions

What is triple pointer?

Example: int x; -- integer int *px= &amp;x; -- pointer to integer int **ppx= &amp;px; -- pointer to pointer to integer int ***pppx= &amp;ppx; -- pointer to pointer to pointer to integer


What happens if we use an integer pointer as a member of structure instead of structure pointer?

By declaring an integer pointer you are declaring that any non-zero reference stored in the pointer is guaranteed to be an integer reference. In order to guarantee the reference is actually a structure, the pointer must be declared as such, because casting an integer to a structure can never be regarded as being type-safe.


What is the effect of various arithmetic operators on a pointers?

Error message, mainly. The following operations are legal: ptr + integer (pointer) ptr - integer (pointer) ptr - ptr (integer)


Why you use float pointer instead of integer pointer?

It depends on what type of data you wish to manipulate.


Are pointers integers?

A pointer holds a memory address, from 0 to the upper limit of your memory (in 32 bit addressing this is up to 2^32, 64 bit is up to 2^64 bytes). So in math terms, a pointer could be considered a non-negative integer. However this is not the same as the integer type used in C and other languages, which refers to how the data at that memory address (the raw bits) is interpreted by the system. So the expression "int *x;" declares a pointer to an integer, but x is a memory address, not a literal C-style integer. The value pointed to by x, however, will be interpreted as a literal C-style integer. It may be easier to see using a pointer to a char: char character = 'C'; char *pointerToCharacter = character; In this case, character is a standard char variable, and pointerToCharacter is a pointer (which is a memory address) that points to the location in memory of a character.


What is the size of integer pointer?

all pointers are 4 bytes in 32 bit system


How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


What is the purpose of the dereference operator when used with a pointer variable?

Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array


Can you make an integer pointer variable to char data?

Of course. But why? int *p = (int *)"string";


Function pointer that will point to a function that takes integer value and return character?

Answerchar (*funcp(int));


What is the only integer that can be assigned to a string?

If you wanted to ask 'Which is the only numeric value that can be assigned to a pointer?', then the answer would be: 0.


What is the easiest way to pass arrays as argument in c?

the simple and efficient way to pass an array is pointer to an array like that int (*p)[30] ; // pointer to an array of integer having 30 element