What will happen if the data type of pointsPossible is changed from double to int?
// This program determines the percentage grade on
// an exam, given the number of questions missed,
// how many points each question was worth,
// and the total points possible.
#include
using namespace std;
int main()
{
int pointsPerQuestion;
int numberMissed;
double percentageGrade;
double pointsPossible;
cout << "Enter the total points possible on the exam => ";
cin >> pointsPossible;
cout << endl;
cout << "Enter the number of points per question => ";
cin >> pointsPerQuestion;
cout << endl
cout <<"Enter the number of questions missed => ";
cin >> numberMissed;
percentageGrade = pointsPossible - numberMissed * pointsPerQuestion / pointsPossible * 100;
cout << endl << "The percentage grade is ";
cout << percentageGrade << "%";
return 0;
}
The operands of the / will both be integers, so any fractional part of the quotient will be lost.
Computer Science & Information Technology
You might also like to view...
The ___________ places components in the specified row and column.
Fill in the blank(s) with the appropriate word(s).
Computer Science & Information Technology
A ____ name is the address of your site.
A. server B. domain C. file D. path
Computer Science & Information Technology
Memory is said to be _____ if contents are lost when power is off.
A. cached B. volatile C. random D. swapped
Computer Science & Information Technology
Consider the peek() operation for the ADT Stack as described by the author. What is its output?
a. true or false a. there is no output b. the object that is at the top of the stack c. the number of items left on the stack
Computer Science & Information Technology