# include <iostream.h>
void main()
{
char x[60];
int y;
cout<< "((use - Between the first and last name. No Space)"<<endl<<"Please Write The Student's Name:";
cin>> x ;
cout<< "Please Enter the Grade Number Of "<<x<<": ";
cin>> y;
if (y>=85){
cout<<"Excellent"<<endl;
}
elseif (y<85||y>=75){
cout<<"Very Good"<<endl;
}
elseif (y<75||y>=65){
cout<<"Good"<<endl;
}
elseif (y<65||y>=50){
cout<<"Pass"<<endl;
}
else { (y<50);
cout<<"fail"<<endl;
}
}
when you run this code
and write any number lower than "75"
you still get "Very Good",
i watched a tutorial for "If"
Url: http://www.youtube.com/watch?v=Fcc8lWmd01Y&feature=related
but still couldn't figure it out.
please try not to write the answer but give me hints
because i wanna solve it with myself =).
Thank you =)
Hint: iostream.h and void main are abominations.
Hint2: Uh... don't use middle alignment. It's hard to read.
Anyways... look at your conditions, and write down in words what they mean. You should see your problem then. And don't watch video tutorials, most of them are crappy. Read the tutorials on this site instead. http://www.cplusplus.com/doc/tutorial/
Hint: The || (logical or) isn't doing what you may be thinking here. || evaluates to true if EITHER condition is true. You need BOTH conditions to be true.
DONE!!!! Thx Guys For Helping =D
i switched from || (or) TO &&(and) and it worked
i know its my bad but still am beginner =)
Thx fun2code =)
Thx hanst99 i will just when am done with my course
but why it is abomination??
iostream.h is deprecated since years (I am pretty sure at least since the 90s), and main should always return an int - modern compilers would simply refuse to compile a void main function.
# include <iostream>
usingnamespace std;
int main()
{
char x[60];
int y;
cout<< "((use - Between the first and last name. No Space)"<<endl<<"Please Write The Student's Name:";
cin>> x ;
cout<< "Please Enter the Grade Number Of "<<x<<": ";
cin>> y;
if (y>=85)
cout<<"Excellent"<<endl;
elseif (y>=75)
cout<<"Very Good"<<endl;
elseif (y>=65)
cout<<"Good"<<endl;
elseif (y>=50)
cout<<"Pass"<<endl;
else
cout<<"Fail"<<endl;
return 0;
}
# include <iostream>
# include <string>
usingnamespace std;
int main()
{
string x;
int y;
cout<<"Please Write The Student's Name:";
getline(cin,x);
cout<< "Please Enter the Grade Number Of "<<x<<": ";
cin>> y;
if (y>=85)
cout<<"Excellent"<<endl;
elseif (y>=75)
cout<<"Very Good"<<endl;
elseif (y>=65)
cout<<"Good"<<endl;
elseif (y>=50)
cout<<"Pass"<<endl;
else
cout<<"Fail"<<endl;
return 0;
}