This is the full code that i actually have so far( I know I should have probably posted this in the first place, sorry about the confusion)
Code:
#include<stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
typedef struct fraction
{
int num, denom;
} fraction;
double Calc_Frac(fraction b)
{
return((double)b.num / b.denom);
}
int main()
{
fraction arrFraction[100];
int i = 0;
int a = 0;
int j;
while (1) {
char name[500][100];
printf("Press 1 to view author info\nPress 2 to enter a name\nPress 3 to view names\nPress 4 to alphabetize names\nPress 5 to clear names\nPress 6 to enter a fraction\nPress 7 to print fraction values\nPress 8 to sort fractions\nPress 9 to analyze fractoins\n");
scanf("%d", &a);
char arr[100];
if (a == 1)
{
printf("----------------\n");
printf("Tim Kononets\n2651763\n");
printf("----------------\n");
}
if (a == 2)
{
printf("----------------\n");
printf("enter a name(or word without any spaces)\n");
scanf("%s", arr);
strcpy(name[i], arr);
i++;
printf("----------------\n");
}
if (a == 3)
{
printf("\n\n-----------------------------\n");
for (int j = 0; j < i; j++)
{
printf("\n%s\n", name[j]);
}
printf("\n\n-----------------------------\n");
}
if (a == 4)
{
int j, k;
for (j = 0; j < i; j++)
{
for (k = 0; k < i - j - 1; k++)
{
if (strcmp(name[k], name[k + 1]) > 0)
{
strcpy(arr, name[k]);
strcpy(name[k], name[k + 1]);
strcpy(name[k + 1], arr);
}
}
}
}
if (a == 5)
{
i = 0;
a = 0;
}
if (a == 6)
{
printf("enter a numerator and a denominator value\n");
scanf("%d %d", &arrFraction[i].num, &arrFraction[i].denom);
i++;
}
if (a == 7)
{
printf("-------------------------\n");
for (j = 0; j < i; j++)
{
printf("%d %d/%d \n", arrFraction[j].num/arrFraction[j].denom, arrFraction[j].num%arrFraction[j].denom, arrFraction[j].denom);
}
printf("\n-------------------------\n\n");
}
if (a == 8)
{
int min;
fraction tmp;
for (i = 0; i < j; i++)
{
min = i;
for (j = i + 1; j < i ; j++)
{
if (Calc_Frac(arrFraction[j]) < Calc_Frac(arrFraction[min]))
{
min = j;
}
}
tmp = arrFraction[i];
arrFraction[i] = arrFraction[min];
arrFraction[min] = tmp;
}
i++;
}
}
system("pause");
return 0;
}
So my problem is with the sorting (a==8) right now, I know that the way the loop is set up, it can only sort up to 2 fractions, so if you could help me with what to put in in order for it to sort every number that is stored into the program that would be great.