Question

Given the constant declaration const float PI=3.14; which the following is a valid use of PI...

Given the constant declaration
const float PI=3.14;
which the following is a valid use of PI in the program?

(A) PI=2*PI;
(B) cout<<PI*7;
(C) ++PI;
(D) cin>>PI;

and why?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :

B option is a correct answer cout<<PI*7;

explanation:

Because you already declared PI as a constant variable
And in rest of the option it's might change the value of PI which is not allowed

Add a comment
Know the answer?
Add Answer to:
Given the constant declaration const float PI=3.14; which the following is a valid use of PI...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

  • In C++ Given the declaration 
char str1[15];
char str2[15] = "Good day"; 
mark the following statements...

    In C++ Given the declaration 
char str1[15];
char str2[15] = "Good day"; 
mark the following statements as valid or invalid. If invalid, explain why. NOTE: Assume that the directive #define _CRT_SECURE_NO_WARNINGS has been entered appropriately in the program. a) if(strlen(str1)>=strlen(str2)) str1 = str2; b) if(strcmp(str1,str2))
 cout << "The strings are equal";

  • Program 2 #include <iostream> #include <cmath> using namespace std; int main() {        const double PI...

    Program 2 #include <iostream> #include <cmath> using namespace std; int main() {        const double PI = 3.141592653;        int degrees;        double radians;        cout << "Enter a value for the degree of an angle\n";        cin >> degrees;        // translate the formula for converting degrees to radians into C++:        //            // degrees x PI        // ------------   = radians        //     180        radians = _____________________________________;        // Refer to p. 127 for help below....

  • Consider the following program in which the statements are in the incorrect order. Rearrange the statements...

    Consider the following program in which the statements are in the incorrect order. Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Formant the output to two decimal places. #include <iomanip> #include <cmath> int main () {} double height; cout << ”Volume of the cylinder = “ <<PI * pow(radius, 2.0) * height << endl; cout...

  • 13.21 Lab: Rational class This question has been asked here before, but every answer I have...

    13.21 Lab: Rational class This question has been asked here before, but every answer I have tested did not work, and I don't understand why, so I'm not able to understand how to do it correctly. I need to build the Rational.cpp file that will work with the main.cpp and Rational.h files as they are written. Rational Numbers It may come as a bit of a surprise when the C++ floating-point types (float, double), fail to capture a particular value...

  • Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6...

    Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6,19,5,3,2,17,40,90,19,80) float ary2tsiz)-to int i,x x-ffx(aryl,ary2, ,siz): cout<<"n The values are: for(1-0:1<" ; it) ary2[i] ; cout<<" coutくくendl ; return 0; oerio int ffx(float all,float bll, int S) int i,p-0; for(i 0: i<s ; i++){ )// end for LD++]=a[i]; return p; if(ifp(ali])) bool ifp(int n)l bool ans-true for (i=2:ic, itt)...

  • PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program...

    PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...

  • Consider the following C++ program // class declaration class person public: -person)i person ( ) person...

    Consider the following C++ program // class declaration class person public: -person)i person ( ) person (int age) i int get_age ()i private: int agei hi // class implementation person::-person age1ih person: :person age-1i) person: :person (int val) 1 ageval; > int person::get_age() return agei h int main) person lucky (42)i person group[1017 person fredi // code qoes here [8 points] Which of the following are valid C++ statements that could be compiled and executed in the main function above?...

  • QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is...

    QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is a different variable) A.y=b-c B.y +z = x C.x = a bi D.x = -(y*z): Ex = (x + (y z): QUESTION 8 Which of the following is a valid variable name according to C++ naming rules? A 2ndName B.%Last_Name C@Month D#55 Eyear03 QUESTION 9 Which library must be included to enable keyboard input? A kbdin B. cstdlib C input Diostream E lomanip QUESTION...

  • Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a...

    Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a class called Circle. The class should have an integer member variable named radius and three member functions; setRadius, getRadius, calArea; the functions' prototypes should be done inside the class declaration and the functions' definitions should come after the main function #include <iostream> using namespace std; const double PI = 3.14; // fill in the declaration of the class Circle here int main() { Circle...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT