write a program to Insert in a sorted list
Answers were Sorted based on User's Feedback
node *insert(node *first,int data)
{node *temp,*trav,*cur;
temp->info=data;
temp->next=NULL;
trav=first;
if(data<trav->info)
{temp->next=first;
first=temp;
return first;
}
while(data>trav->info&&trav->next!=NULL)
{cur=trav;
trav=trav->next;
}
if(data>trav->info&&trav->next==NULL)
trav->next=temp;
else
{cur->next=temp;
temp->next=trav;
}
return first;
}
Is This Answer Correct ? | 10 Yes | 5 No |
Answer / prof.muthu(9962940220)
PLEASE INSERT IN SORTED ORDER....SO,THERE IS NO DIFICULTY OF
RE-ARRANGING THE ELEMENTS...
GOT IT...?
BY THE GREAT PROF.MUTHU
PH:9962940220
Is This Answer Correct ? | 3 Yes | 5 No |
Answer / kathiresan
node *SLSortWiseInsert(node *START, int data)
{
node *newnode;
if(START == NULL)
{
START = (node *)malloc(sizeof(node));
START->data = data;
START->link = NULL;
return START;
}
else if(data < START->data)
{
newnode = (node *)malloc(sizeof(node));
newnode->data = data;
newnode->link = START;
return newnode;
}
else if((data > START->data) && (START->link == NULL))
{
printf("Inside this condition\n");
newnode = (node *)malloc(sizeof(node));
newnode->data = data;
newnode->link = NULL;
START->link = newnode;
return START;
}
START->link = SLSortWiseInsert(START->link,data);
return START;
}
Is This Answer Correct ? | 1 Yes | 8 No |
main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }
main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }
main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.
abcdedcba abc cba ab ba a a
posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come
What is the hidden bug with the following statement? assert(val++ != 0);
Give a one-line C expression to test whether a number is a power of 2.
void main() { int i=5; printf("%d",i++ + ++i); }
main() { int i=10; i=!i>14; Printf ("i=%d",i); }