I don't know what is wrong.

I'm trying to write a program to tell you your grade depending on the numerical value that is put in and I don't know what I am doing wrong. when I put in the numerical value all it does is close the program. This is my last resort. Please Help

#include <stdio.h>

int main(void)

{
int numbergrade;
int a;
int b;
int c;
int d;
int f;

printf("please enter number grade here");
if(numbergrade>92)
{
scanf("%d",&a);
}
else if(numbergrade>84)
{
scanf("%d",&b);
}
else if(numbergrade>74)
{
scanf("%d",&c);
}
else if(numbergrade>69)
{
scanf("%d",&d);
}
else if(numbergrade<58)
{
scanf("%d",&f);
}
system("pause");
return 0;
}
You are only asking for input when you call scanf(), so you should probably use that before you actually try to check what numbergrade is.

Also, what is the point of all the a~f variables? I'd have thought you were going to output what the user's grade was, not declare several integers that happen to share the names with the grades you are looking for.
I was using scanf like that in terms of when it gets to the specific requirement it will stop and spit out the letter grade.
I was actually trying to give each set of numbers it's specific grade.
Was that an issue?
I'm just stating and it is really confusing for me I honestly don't know what I'm doing wrong and posting here was truly my last resort
If you want to print out the letter 'A', for example, you don't need to declare a variable for that. Just print it out like you did the text asking the user for their input.

You will also want to have a scanf() statement to read in the numerical grade.

Probably the main issue is that you are trying to check the value of numbergrade when it has not been initialized anywhere.
so are you saying that because the numbergrade has not been declared yet then it is not going to catch onto it until it is input by the user
numbergrade was declared; the problem is that it has been given no value. You then attempt to check its value in your if statement conditions.

I'm not sure what you mean by "catch onto it".
so should I take out all of the scanf's except the last one
I don't think you are understanding what I am saying; please re-read my previous posts and make sure you understand exactly what the problem I am identifying is. Just randomly making changes that sound like what I was mentioning will not help you.
I'm not understanding
Topic archived. No new replies allowed.