1.
You want to spice up your resume before the career fair, so you decide to update your GPA using the program below. What is the GPA that you will have on display for future employers?
#include <iostream>
using namespace std;
int main() {
double GPA = 3.52;
int updatedGPA = int(GPA);
cout << "GPA: " << updatedGPA;
}
3.0
- Its correct to think that your GPA will be rounded down, but what else happens when you convert from
int
todouble
? 3
- Converting to an
int
always rounds down to the nearest integer, so I do not recommend using type conversions to build your resume… especially if you’re close to4.0
. 4.0
- Converting to an int will round your GPA, but not in the direction that you were hoping for… what else happens when you convert from
int
todouble
? 4
- Converting to an int will round yor GPA, but not in the direction that you were hoping for.
- Error!
- No errors here! Type conversions are perfectly legal in C++!