Converting Time how can I improve my code? : <p>Just started programming so any suggestion or constructive criticism would be much appreciated. I'm pretty sure there are ways to shorten this I just don't know how, especially the use of functions.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int input, check = 1, ans;
int menu ();
int convert24(int hour, int min, int sec, int meridiem);
int convert12(int hour, int min, int sec, int meridiem);
int result(int hour, int min, int sec, int meridiem);
void processAnother();

int main()
{
do
{
    menu();
    processAnother();
    system("cls");
}while (ans = 'y');

}
int menu ()
{
    int hour, min, sec, meridiem;
    printf("[1] Convert to 24-hour notation\n");
    printf("[2] Convert to 12-hour notation\n");
    printf("[3] Quit\n");
    scanf("%d", &amp;input);


    switch(input)
    {
        case 1 :
            {
                printf("Enter hours (1-12):minute(1-59):seconds(1-59): ");
                scanf("%d %d %d", &amp;hour, &amp;min, &amp;sec);
                printf("[1] AM or [2] PM: ");
                scanf(" %d", &amp;meridiem);
                return convert24(hour, min, sec, meridiem);
                break;
            }
        case 2 :
            {
                printf("Enter hours(1-24):minute(1-59):seconds(1-59): ");
                scanf("%d %d %d", &amp;hour, &amp;min, &amp;sec);
                printf("[1]AM or [2]PM: ");
                scanf(" %d", &amp;meridiem);
                return convert12(hour, min, sec, meridiem);
                break;
            }
        default :
            {
                printf("Goodbye :)");
                exit(0);
            }
    }
}
int convert24(int hour, int min, int sec, int meridiem)
{
    if ((hour &gt; 12 || hour &lt; 0))
    {
        printf("\nError! Invalid Hour\n");
        check = 0;
    }
    if ((min &gt;= 60 || min &lt;0))
    {
        printf("\nError! Invalid Minute\n");
        check = 0;
    }
    if ((sec &gt;= 60 || sec &lt;0))
    {
        printf("\nError! Invalid Second\n");
        check = 0;
    }
    if (meridiem &gt; 2 || meridiem &lt; 0)
    {
        printf("\nError! Invalid Meridiem\n");
        check = 0;
    }
    if (check == 1)
    {
        if (meridiem == 1)
        {
            if (hour == 12)
            {
                hour = 0;
                result(hour, min, sec, meridiem);
            }
            else
            {
                result(hour, min, sec, meridiem);
            }
        }
        else if (meridiem == 2)
        {
            if (hour == 12)
            {
                hour = 12;
                result(hour, min, sec, meridiem);
            }
            else
            {
                hour+=12;
                result(hour, min, sec, meridiem);
            }
        }
    }
    processAnother();
}
int convert12(int hour, int min, int sec, int meridiem)
{
    if ((hour &gt; 24 || hour &lt; 0))
    {
        printf("\nError! Invalid Hour\n");
        check = 0;
    }
    if ((min &gt;= 60 || min &lt;0))
    {
        printf("\nError! Invalid Minute\n");
        check = 0;
    }
    if ((sec &gt;= 60 || sec &lt;0))
    {
        printf("\nError! Invalid Second\n");
        check = 0;
    }
    if (meridiem &gt; 2 || meridiem &lt; 0)
    {
        printf("\nError! Invalid Meridiem\n");
        check = 0;
    }
    if (check == 1)
    {
        if (meridiem == 1)
        {
            if (hour &lt;= 12)
            {
                result(hour, min, sec, meridiem);
            }
            else
            {
                hour -= 12;
                result(hour, min, sec, meridiem);
            }
        }
        else if (meridiem == 2)
        {
            if (hour &lt;= 12)
            {
                result(hour, min, sec, meridiem);
            }
            else
            {
                hour -= 12;
                result(hour, min, sec, meridiem);
            }
        }
    }
    processAnother();
}
int result(int hour, int min, int sec, int meridiem)
{
    char *x;
    int y;
    if(meridiem == 1)
    {
       x = "AM";
    }
    else if (meridiem == 2)
    {
       x = "PM";
    }
    if (input == 1)
    {
        y = 24;
    }
    else if (input == 2)
    {
        y = 12;
    }
    printf("The %d-hr Notation is : %d:%d:%d %s\n",y, hour, min, sec, x);
    return;
}
void processAnother()
{
    printf("Process another [y/n]");
    scanf("%c", &amp;ans);
    return;
}
</code></pre>

<p>Thank you very much.</p>
