Program for reading floating point numbers


Question 1:

a) What is the least number of times the body of a while loop can be executed?

b) What is wrong with the given loop:

while (n<=100)
sum += n*n;

c) Write a program which reads the prices of zero or more items, and displays the total price with 14% sales tax added.

Question 2: Write a program which reads in two floating point numbers and then performs one of four operations on them: addition, subtraction, multiplication or division. The program should ask the user which one of the operations to perform. Use a switch statement to perform the right operation and display the result.

Question 3: The given program is not compiling. Describe the problem and rewrite the codes below so as to make the program compile properly.

#include
using namespace std;
void PrintCurved(int grade);
int main()
{
   int studentNo, grade;
   cout << "Enter student number and grade:";
   cin >> studentNo >> grade;
   PrintCurved(grade);
   return 0;
}
void PrintCurved(int grade)
{
   cout << "The curved grade for student ";
        << studentNo << " is " 
        << grade + 10 << endl;
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Program for reading floating point numbers
Reference No:- TGS06121

Expected delivery within 24 Hours