warning: assignment makes integer from pointer without a cast

This is a discussion on warning: assignment makes integer from pointer without a cast within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> /* Prompts user to enter the score */ int getScore(int numScore); /*Converts a numberic score to a ...

  1. #16
    Registered User
    Join Date
    Feb 2006
    Location
    Philadelphia, PA
    Posts
    27
    Code:
    #include <stdio.h>
    
    /* Prompts user to enter the score */
    int getScore(int numScore);
    
    /*Converts a numberic score to a letter grade */
    
    char convertGrade(int numScore);
    
    /*Displays the original numeric score, the corresponding letter grade
     *if the score is valid, and an appropriate eror message if the score
     *if the score is not valid
     */
    
    void showGrade(int, char);
    
    int
    main(void)
    {
    
            char    letterGrade, printGrade;
            int     numScore;
    
            getScore(numScore);
    
            letterGrade = convertGrade(numScore);
    
            showGrade(numScore, letterGrade);
    
            return(0);
    }
    
    /*Fuction that prompts user to enter the score */
    
    int getScore(int numScore)
    {
            printf("Please enter numeric grade  and press return>");
            scanf("%d", &numScore);
            return numScore;
    }
    
    /*Function converts a numeric score to a letter grade */
    
    char convertGrade(int numScore)
    {
            char letterGrade;
    
            if(numScore >= 90)
              letterGrade = 'A';
            else if(numScore >= 80)
              letterGrade = 'B';
            else if(numScore >= 70)
              letterGrade = 'C';
            else if(numScore >= 60)
              letterGrade = 'D';
            else if(numScore <= 59)
              letterGrade = 'F';
            else if(numScore > 100 && numScore < 0)
              letterGrade = 'Z';
           return letterGrade;
    }
    
    /*Function prints out the letter grade */
    void showGrade(int numScore, char letterGrade)
    {
    
            if (letterGrade='Z')
            printf("\nYour score of %.2f is not valid.\n", letterGrade);
            else
            printf("\nYour score of %.2f is a %c grade.\n", numScore, letterGrade);
    
    }
    Finally it compiles! Now when I run it, i always get the same result

    Code:
    Please enter numeric grade  and press return>98
    Your score of 0.00 is not valid.
    Any suggestions?

  2. #17
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
            if (letterGrade='Z') // this is an assignement you want  letterGrade=='Z'
    //        printf("\nYour score of %.2f is not valid.\n", letterGrade);
            printf("\nYour score of %c is not valid.\n", letterGrade);  // lettergrade is a char
            else
    //        printf("\nYour score of %.2f is a %c grade.\n", numScore, letterGrade);
            printf("\nYour score of %2d is a %c grade.\n", numScore, letterGrade); // numScore is int
    Kurt

  3. #18
    Registered User
    Join Date
    Feb 2006
    Location
    Philadelphia, PA
    Posts
    27
    I finally got it to run perfectly. Thank you for your help everyone. If someone needs the code I can post it.

    Andriy

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 05:55 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. assignment makes pointer from integer
    By crescen7 in forum C Programming
    Replies: 4
    Last Post: 06-25-2002, 10:08 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 3
    Last Post: 01-14-2002, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21