Hello everyone i just joined the forum and this is my first post so if there is something that i should fix-edit plz tell me.
I just got in college and we have some home work to do.
so the excersice is rly simple for you i guess, but for me its hard.
Here is what i have to do and btw my english are not that great so... :S
I have to write a programm that will have a "menu" for the user manipulate a talbe of 5 "spots" ( i mean like P[5], but dunno how the "spots" are called in english, places or what ever they are)
The commands are: 0= scan a table of 5 "spots"
1=print the table
2=sort the table ( ascending )
3=find minimun,maximun,avg of the numbers given.
4=exits programm
The table is integer only.
The thing is that i have to do each one using funtions like 1 function to scan,one to print,one to sort,one for min,max.
I dont want you guys to write the programm.
I have written itcompiled,and worked perfectly BUT it is without function
The scan and print i have managed,i think.
But i cant understand how to return a table from a function and functions confuse me a lot and thats were i need your help.
below ill list the body of the functions that iv managed to write so far, if you also need the full program let me know and ill put it on.
to scan the table ,the function will be called inside a for loop for i=0-5 :
for the buble sorting:Code:int scan() {int num; scanf("%d",&num) return num; }
the print and the min,max,avg i havent done yet.Code:int bubble() {int i,j,P[i]; for (j=0; j<5; j++) { for (i=0; i<4; i++) { if (P[i]>P[i+1]) { temp=P[i]; P[i]=P[i+1]; P[i+1]=temp; } } } }
and the questions are : HOW WILL I CALL THE FUNCTION INTO MAIN() TO WORK PROPERLY?? HOW CAN I RETURN A TABLE FROM A FUNC???
thank you in advance
~Cursy
(sorry for the long post but wanted to show you that i tryed and not just came here and ask you to do it, and also to give as much info as possible)
EDIT: USING <STDIO.H>