![]() |
'C-' and 'C+'
:
char ch;After I input the character: :
std::cin>> ch;And check for the value EX: if((ch=='C-') || (ch=='C+')) do ....... But it not seems to be working, I get an error that C- and C+ are dublicated values..... |
try double quotes instead of single quotes
:
|
Would reading more than one character into a char have anything to do with it?
|
good point you will have to use strcmp to compare the strings
|
char allocates memory for only one character. While each C- and C+ consists of two characters. So if you want to compare C- with C+, you will have to declare ch as a string not a char. And then you will have to use double quotes in the if, because its a string.
|
Thanks Guys that was helpful. I'll Post the code soon
|
Ok, here is the code; I would appreciate any comments and feedback, Thanks.
Its little program that calculate your GPA :
#include <iostream> |
Looks good. However, I would suggest putting all those grade boundaries in an array.
|
mmm... u mean sth like this:
EX: int A[10] grades{A,A-,B+,.....} if so how will I assign values. |
This is how I would do it:
:
#include <iostream> |
| All times are GMT -5. The time now is 3:51 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC