samedi 24 décembre 2016

My code jump to else immediately?(C language)

#include <stdio.h>
int printMenu(int);
int studentglobal;
float getCarryMark(float);
int cm1;


main()
{
    printf("-----------------------------------------------------\n");
    printf("\t\tTotal Score calculator\n");
    printf("-----------------------------------------------------\n");
    int counter, x, studentcount = 1,sum = 0 ;

    x = printMenu(studentglobal);

    for (counter = 0; counter < x; counter++)

    {
        studentcount = studentcount + counter;
        printf("Student : %d \n", studentcount);
        float crym;
        crym = getCarryMark(cm1);

        if (crym >= 0 && crym <= 50)
        {
            printf("right range!!\n");
        }
        else
        {
            printf("INVALID RANGE!!!\n");
        }
    }

}

int printMenu(int nstudent)
{
    printf("Enter no of student: ");
    scanf("%d", &nstudent);
    return(nstudent);
}

float getCarryMark(carrymark)
{
    printf("Enter your carrymarks: ");
    scanf("%f", &carrymark);
}

so actually when i enter 200 and it show invalid range!!..but when i enter 20 it still show invalid range!!!? it somehow skip the if statement. Please dont bother the other part, if i have any mistake tell me please..

thanks in advance:)

Aucun commentaire:

Enregistrer un commentaire