Question

In: Computer Science

Is it fine to enter double before const in c++? Just like this double const ...

Is it fine to enter double before const in c++?

Just like this
double const ...

Solutions

Expert Solution

Yes, it is fine to enter double before const in c++

The following code depict the condition for the given case.

Code in text format:-

#include <iostream>
using namespace std;

int main()
{
double const a=10;
cout<<a;
}

Output:-

Note:-

1.we cant change the constant value throughout the program ,if we try to modify the constant we will get an error.

The following depicts the case:

Code in text format:-

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double const a=10;
a=a+10;
cout<<a;
}

Output:-

If you have any queries please comment

If you liked the answer please give me a thumbs up.Thanking you


Related Solutions

C language <stdio.h> use double and const Write a program that asks the user for the...
C language <stdio.h> use double and const Write a program that asks the user for the radius of a circle (as a double) and displays the diameter, circumference, and area of the circle. Use a constant of 3.14159 as the value of pi. Have a blank line between the input and the output. Follow the 3 steps in the Information Processing Cycle - Input, Processing, and Output. The formulas needed are: diameter = 2 * radius circumference = 2 *...
Submit a c++ file: 2. Write a program that defines the named constant PI, const double...
Submit a c++ file: 2. Write a program that defines the named constant PI, const double PI = 3.14159;, which stores the value of p. The program should use PI and the functions listed in Table 6-1 to accomplish the following: a. Output the value of Pi Output the value of Pi. b. Prompt the user to input the value of a double variable r, which stores the radius of a sphere. The program then outputs the following: i.   The...
what is a const in C++? what does const mean in these functions
what is a const in C++?what does const mean in these functions-> " void idkwhattonameit( const name) {} "-> " void idkwhattonameit2( const &name) {} "-> " void idkwhattonameit3( const * name) {} "-> " void idkagain (const unique_ptr < Name > name_uPtr)"
C language <stdio.h> ONLY USE double and const int Write a program to convert Celsius temperature...
C language <stdio.h> ONLY USE double and const int Write a program to convert Celsius temperature to Fahrenheit temperature. The formula for converting Celsius temperature into Fahrenheit temperature is:    F = (9 / 5) * C + 32 Create integer constants for the 3 numbers in the formula (9, 5, and 32).  Follow the 3 steps in the Information Processing Cycle - Input, Processing, and Output. Convert the 9 to a double when converting the temperature (use type casting). Have a...
class Point3d { public: Point3d(double x, double y, double z); Point3d(const point3d& p); void setX(double x);...
class Point3d { public: Point3d(double x, double y, double z); Point3d(const point3d& p); void setX(double x); void setY(double y); void setZ(double z); double getX() const; double getY() const; double getZ() const; point3d& operator=(const point3d& rhs); private: double x; double y; double z; }; Given the Point class above, complete the following: 1. Write just the signature for the overloaded addition operator that would add the respective x,y, and z from two point3d objects. 2. What is the output of the...
Write a C program that asks the user to enter double values (the values can be...
Write a C program that asks the user to enter double values (the values can be positive, zero, or negative). After entering the first double value, the program asks "Would you like to enter another value?", and if the user enters Y or y, the program continues to get additional values and stores these values into a double array (for up to 100 values — use a symbolic #define constant to specify the 100 size limit). The program will need...
C++ programming question class Address { public: Address(const std::string& street, const std::string& city, const std::string& state,...
C++ programming question class Address { public: Address(const std::string& street, const std::string& city, const std::string& state, const std::string& zip) : StreetNumber(street), CityName(city), StateName(state), ZipCode(zip) {} std::string GetStreetNumber() const { return StreetNumber; } void SetStreetNumber(const std::string& street) { StreetNumber = street; } std::string GetCity() const { return CityName; } void SetCity(const std::string& city) { CityName = city; } std::string GetState() const { return StateName; } void SetState(const std::string& state) { StateName = state; } std::string GetZipCode() const { return ZipCode; }...
Base Class class TransportationLink { protected: string _name; double _distance; public: TransportationLink(const string &name, double distance);...
Base Class class TransportationLink { protected: string _name; double _distance; public: TransportationLink(const string &name, double distance); const string & getName() const; double getDistance() const; void setDistance(double); // Passes in the departure time (as minute) and returns arrival time (as minute) // For example: // 8 am will be passed in as 480 minutes (8 * 60) // 2:30 pm will be passed in as 870 minutes (14.5 * 60) virtual unsigned computeArrivalTime(unsigned minute) const = 0; }; #endif Derived Classes...
double maxArea(Rectangle a, Rectangle b, Rectangle c) {     double width;     double length;     double...
double maxArea(Rectangle a, Rectangle b, Rectangle c) {     double width;     double length;     double area = 0;     area = width * length;     cout << "\n***maxArea called" << endl;          cout << "***       rectangleCount = " << Rectangle::rectangleCount << endl << endl;    } Compete this code to find the maximum area of rectangle between a,b,c
Make a function definition in C for the following: void insert (double *b, int c, double...
Make a function definition in C for the following: void insert (double *b, int c, double s, int pos); //Insert value s at position pos in array. //needs: // c > 0, pos >= 0, and pos <= c-1. Elements b[0]...b[c-1] exist. //this will do: //Elements from indexes pos up to c-2 have been moved up to indexes pos+1 up to c-1. The value s has been copied into b[pos]. //Note: the data that was in b[c-1] when the function...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT