lio180

hi all,

i have i this question for my project, but i have some problems with sorting the names of students by alphabetical order and order the names by their scores.
the names are strings and the scores are of type int.

this is the question and i want functions for the highlighted.

Project Title: Arithmetic Test Tool
Write a c program to test studentsâ€™ knowledge of mental arithmetic.
Your program should keep track of a list of students who took a test with their scores in a file. The different types of operations tested by your system are as follows:
Multiplication: is limited to integer numbers only with 2 levels of difficulty.
1- single digit with single digit (score of 1 for correct answer.)
2- double digit with single digit (score of 2 for correct answer)

Division: division is limited to integer division. Thus the program will ask for result of division and remainder. 2 levels of difficulty.
1- double digit numerator (score of 2 for correct answer: 1 for correct division result and 1 for correct remainder)
2- 3 digit number for numerator (score of 3 for correct answer: 2 for correct division result and 1 for correct remainder)
For both cases the denominator is between 2 and 9.

Integer addition and subtraction: two levels of difficulty.
1- 2 digit with 2 digit numbers ( 1 for correct answer)
2- 3 digit with 3 digit numbers (2 for correct answer)

Floating point addition and subtraction: two levels of difficulty.
1- 1 digit before decimal point and one digit after decimal point. (2 for correct answer)
2- 1 digit before decimal point with 2 digits after decimal point. (3 for correct answer)
1- List the names of those who took the test with their scores arranged in increasing or decreasing order.
2- List the names in alphabetical order.
3- start the test.
If the user chooses to start the test, then the program will ask for his name and if he has already taken the test; the program will display his previous score.
The program gives 10 questions chosen randomly from all cited categories. The questions are displayed one by one. Once the user answers one question the program check if it is correct or not and gives him the score for that question. If the answer is wrong, the program displays the right answer. After that it will display the next question and so on. Once the 10 questions are answered, the program will find the new score. If it is higher than the old one, it will delete the old and saves the new one with the student name. If not it will keep the old score.
The type of the operation and the numbers used in that operation are selected randomly.

Note: The function rand() will return a pseudo random number from 0 to RAND_MAX which is the maximum value in the int type. In order to limit your number from 0 to n, make the returned value % (n+1). By using rand() only, your program will generate the same sequence during each execution. To avoid this problem insert the following statement at the beginning of your main function. srand(time(NULL));
For real values generate random integers, then divide it by 10 to get a number with 1 digit after decimal point, or divide it by 100 to get 2 digits after decimal point.
You need to insert 2 include statements <stdlib.h> and <time.h>.

plz help me out with it...

Ancient Dragon 5,243

>>this is the question and i want functions for the highlighted.
Well, you're not going to get it here. You will have to write the function yourself.

How to sort the names will depend on how you have the names stored in memory. There are lots of sort algorithms, but the easiest to code is the bubble sort. You will need to write two different sort algorithms, one that sorts the strings and the other that sorts the integers.

jbennet 1,618

Yep. Bubble sort is probably easiest (not the most complex, nor the most efficient though).

Just remember that you cant just use == to compare strings in C. I know in C++ the STL has a function for comparing strings, dont know about C.

Ancient Dragon 5,243

I know in C++ the STL has a function for comparing strings, dont know about C.

strcmp() is a case-sensitive string comparison. Some compilers implement a case-insensitive comparison such as stricmp()

printrobin -3

Yes, Bubble sort is the easiest or effective method to sort the list of names.

Editor's Note:
Why are you echoing jbennet's post? Is it to get your signature spam in?