if the answer is 90 through 100 it displays an A if the number is between 80 and 89 it will Display a B, but if its any number less then that it wont work. what am i missing?

if((int) total >= 90 && total <= 100) {
		printf("%c          \n ", gradeLetter1 );
	}
	else if((int) total >= 80 && total <= 89) { 
		printf("%c \n", gradeLetter2);
	}
		else if((int) total >= 70 && total <= 79) {
			printf("c% \n", gradeLetter3);
		}
			else if((int) total >= 60 && total <= 69) {
				printf("c% \n", gradeLetter4);
			}
				else if((int) total <= 59) {
					printf("You have Failed with a %d percent \n");
				}
		


	return 0;

First question, what do you hope to gain by casting this?

if((int) total >= 90 && total <= 100)

First question, what do you hope to gain by casting this?

if((int) total >= 90 && total <= 100)

Can you clarify, what you mean, when you ask, "what do you hope to gain"
there's a printf statement right below it if you didnt read that.

Please look at the code below

#include <stdio.h>

int main()
{
	int total = 60;
	char gradeLetter1 = 'A';
	char gradeLetter2 = 'B';
	char gradeLetter3 = 'C';
	char gradeLetter4 = 'D';

	if((total >= 90) && (total <= 100)) 
	{
		printf("%c          \n ", gradeLetter1 );
	}
	else if((total >= 80) && (total <= 89)) 
	{ 
		printf("%c \n", gradeLetter2);
	}
	else if((total >= 70) && (total <= 79)) 
	{
		printf("%c \n", gradeLetter3);/*c% should be %c*/
	}
	else if((total >= 60) && (total <= 69)) 
	{
		printf("%c \n", gradeLetter4);/*c% should be %c*/
	}
	else if(total <= 59) 
	{
		printf("You have Failed with a %d percent \n", total);
	}
	return 0;
}

or better

#include <stdio.h>

int main()
{
	int total = 55;
	char gradeLetter1 = 'A';
	char gradeLetter2 = 'B';
	char gradeLetter3 = 'C';
	char gradeLetter4 = 'D';

	if(total >= 90) 
	{
		printf("%c          \n ", gradeLetter1 );
	}
	else if(total >= 80) 
	{ 
		printf("%c \n", gradeLetter2);
	}
	else if(total >= 70) 
	{
		printf("%c \n", gradeLetter3);/*c% should be %c*/
	}
	else if(total >= 60) 
	{
		printf("%c \n", gradeLetter4);/*c% should be %c*/
	}
	else if(total <= 59) 
	{
		printf("You have Failed with a %d percent \n", total);
	}
	return 0;
}

dude i didnt even realize my percent sign was backwards wow thanks btw i have all the chars declared i just didnt show me whole code, but thanks man

int grade = 87;
char letter[6] = "FDCBAA";

int main(void)
{
   printf("grade %d is letter '%c'\n", grade, letter[(grade>59)?grade/10-5:0]);
   return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.