Question:
Hi I need need help in C programming?
?
2011-04-04 22:12:34 UTC
Hi I need help in C programming... i need full programming of ‘C’ Program to accept 10 numbers from user, store these numbers in an array and sort an array elements in ascending order by using dynamic memory allocation....
please give the full program and also explain it..please don't provide any link or just logic,,, i need full program of that question...
thanks in advance..have nice day
Four answers:
2011-04-04 23:17:47 UTC
http://ideone.com/Cn534



Enjoy. If you have any *specific* questions about something you don't understand, then just add additional information to your post.
sam_splendid
2011-04-05 09:17:39 UTC
use for loop till 10 to accept numbers

use scanf()

use malloc() for allocating 10 integers

learn sorting algorithms like bubble sort, insertion sort, quick sort.

pass your array to sorting algorithm

free your array by using free()



happy programming :)
ֆɦσ⎷ση
2011-04-05 06:48:55 UTC
//Your Question is not Specific to Understand. This Code Will Work as Ascending & Descending

order.May Be This Code is Nearly Answer ......That You Asked... Just Follow The Instruction in The Marked( /* */ ) Area.......Thanks



#include

#include



typedef struct node

{

int val;

struct node *next;

}*listptr;



listptr getnode (void);



void main()

{

int i,x;

listptr a,b,c;

b = getnode();

//generate the numbers randomly and put them in the list

randomize();

for(i = 0;i<5;i++)

{

x = rand();/*the function is r-a-n-d without the hyphens,don't know why it's coming as **** */

a = getnode();

a->val = x;

a->next = NULL;

if(i != 0) b->next = a;

if(i == 0) c = a;

b = a;

}

b = c;

printf("\nOriginal list :-\n");

for(a = c;a != NULL;a = a->next)

printf("%d ",a->val);

//Now sort them

for(a = c;a->next != NULL;a = a->next)

for(b = a->next;b != NULL;b = b->next)

if(a->val > b->val) /*for ascending order '>',for descending order.'<' */

{

x = a->val;

a->val = b->val;

b->val = x;

}

printf("\nSorted list :-\n");

for(a = c;a != NULL;a = a->next)

printf("%d ",a->val);

}

listptr getnode (void)

{

listptr a;

a=(listptr)malloc(sizeof(struct node));



return(a);

}
?
2011-04-05 06:36:44 UTC
It is better you have your work out and then ask people to help you.

Change your attitude man while asking for help.

It is not morally correct from our side to answer exam questions.

Cheers


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...