jeudi 3 décembre 2015

Wrote a code but there are some errors

#include <stdio.h>
#include <stdlib.h>

int randomNumber(int);
void checkNumber(float,float);
int main()
{

    int number ,guess = 0,check=0;
    char choice='Y';
    number = randomNumber();
    printf("%d\n",number);

    while(1)
    {
        switch(choice)
        {
            case 'Y':
                printf("Guess the number that is between 1-20:\n");
                scanf("%d",&guess);
                checkNumber(number,guess);
                break;
            case 'N'
                printf("BYE BYE....\n")
                break;
            default:
            printf("Please enter a valid choice\n");
        }
        if(check==0 && choice == 0 'Y')
        {
            printf("***********\nDo you want to contiune to guess number?(Y/N)\n");
            scanf("%c",&choice);
            printf("***********\n");

        }
        else break;
    }
    return 0;
    int randomNumber()
    {
        return (rand()%10)
    }
}

void checkNumber()

if (n<g)
{
    printf("Guess a lower value!\n\n");
    return 0;
}

else if (n<g)
{
    printf("Guess a higher value!\n\n");
    return 0;
}
else
{
    printf("****Cong.,You guessed the number ****\n\n");
    return 1;
}

a program to get the user to guess the number that the program has picked as the lucky number. It uses one for loop and plenty of if statements but there are some logical or syntax errors.I couldn't solve the problem.any help is appreciated, thanks in advance.




Aucun commentaire:

Enregistrer un commentaire