Explicit type conversion


Question1. The statement #include   is normally added at the beginning of a program. What is the purpose of this statement?

Question2. Explain what is meant by explicit type conversion.

Question3. Determine the trace table for the following program:

1. //Program to illustrate arithmetic operations

2. #include

3. Using namespace std;

4.

5. int main() {

6. int ThisVal, ThatVal, ThisVal2;

7. const int TheVal = 5;

8.

9. ThisVal = 3;

10. ThatVal= 2 * ThisVal + 7 / ThisVal * TheVal;

11. ThisVal2 = ThatVal * ThisVal / 9 + 8;

12.

13. cout << “ThisVal = “ << ThisVal;

14. cout << “; ThatVal = “ << ThatVal << endl;

15. cout << ThisVal2 = “ << ThisVal2;

16.  cout << “; TheVal = “ << TheVal << endl;

17.

18. return 0;

19.  }

Question4. Write a program that displays all the odd numbers from 1 to 100 on separate lines. Use for loop.

Question5. What is the output when the following code fragment is executed?

  char ch;
  char title[] = "Programming";
  ch = title[1];
  title[3] = ch;
  cout << title << endl;
  cout << ch << endl;

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

Question7. What is wrong with the following loop:

      While (n<=100)
      Sum += n*n;

Question8. Write a program that reads the prices of zero or more items, and displays the total price with 14% sales tax added. (Hint: the program will know when the last price has been read if a price of 0.00 is entered)

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

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Explicit type conversion
Reference No:- TGS05908

Expected delivery within 24 Hours