d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Dumb Question. > Using The Not Statement.
Add Reply New Topic New Poll
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Mar 3 2014 05:24am
Code

#include <iostream>
using namespace std;
int main()
{
char year;
float gpa;

cout << "What year student are you ?" << endl;
cout << "Enter 1 (freshman), 2 (sophomore), 3 (junior), or 4 (senior)" << endl << endl;
cin >> year;

cout << "Now enter your GPA" << endl;
cin >> gpa;

if (gpa >= 2.0 && year == '4')
cout << "It is time to graduate soon" << endl;

else if (year != '4'|| gpa < 2.0)
cout << "You need more schooling" << endl;

return 0;
}


Exercise 1: How could you rewrite gpa >= 2.0 in the first if statement using the NOT operator?

I'm not sure how the fuck they want me to write that besides

Code
if (gpa != 2.0)


Which to me doesn't make fucking sense in terms of syntax for the if statement. I might be too damn tired to see the correct answer but what I am doing wrong? Or is that question really that stupid?
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Mar 3 2014 06:01am
I found it in my book and rewrote it as:

Code

if (!(gpa < 2.0))


I must be fucking tired.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll