Want this question answered?
#include<iostream> struct shape { virtual double perimeter() const = 0; virtual double area() const = 0; }; struct circle : shape { circle (double radius): r(radius), pi(4*atan(1)) {} double perimeter() const { return 2*pi*r; } double area() const { return pi*r*r; } private: double r; const double pi; }; struct rectangle : shape { rectangle (double width, double height): w(width), h(height) {} double perimeter() const { return 2*(w+h); } double area() const { return w*h; } private: double w; double h; }; int main() { using std::cout; using std::endl; circle c (3.0); cout << "Circle with radius 3.0\n"; cout << "\tPerimiter: " << c.perimiter() << '\n'; cout << "\tArea: " << c.area() << '\n'; cout << endl; rectangle r (4.0, 5.0); cout << "Rectangle with width 4.0 and height 5.0\n"; cout << "\tPerimiter: " << r.perimiter() << '\n'; cout << "\tArea: " << r.area() << '\n'; cout << endl; }
void draw_box (const unsigned size) { if (!size) return; // size must be non-zero! const char star {'*'}; // asterisk const char nl {'\n'}; // newline if (size==1) { // a box of size 1 is just a single asterisk std::cout << star << nl; return; } // else if (1 < size) ... // the top and bottom lines are the same const std::string line (size, star); // hollow line (spaces) const std::string hollow (size-2, ' '); // draw the top line std::cout << line << nl; // draw the middle lines (if size>2) for (unsigned i=2; i<size; ++i) std::cout << star << hollow << star << nl; // draw the bottom line std::cout << line << nl; }
Outside of a class definition, constants can be declared with the define function. The function has two arguments; the name of the constant (a string), and the value of the constant (any variable type).Inside a class definition, constants can be declared with the const keyword. Type the word const, the name of the constant in the form of how it will be called later, an "equals sign," then the desired value of the constant.In both cases, here is an example.
anti derivative of ax^n is (a/n+1)x^(n+1) a is a const n is power of variable and answere6x^2
#include<stdio.h> const unsigned int rows = 10; const unsigned int cols = 3; int table[rows][cols]; int square (const int n) { return n * n; } int cube (const int n) { return n * n * n; } void initialise_table (void) { int x, y, val; for (x=0; x<rows; ++x) { val = x+1; table[x][0] = val; table[x][1] = square (val); table[x][2] = cube (val); } } int main (void) { int x, y; initialise_table (); printf ("Value\tSquare\tCube\n"); for (x=0; x<rows; ++x) { printf("%d\t%d\t%d\n", table[x][0], table[x][1], table[x][2]); } return 0; }
Everything. "inline" refers to functions, "const" refers to variables.
Declaring a Constant: We can declare a constant using the keyword "const". E.g. const abc='a';const number=10; const number[10]={1,2,3,4,5,6,7,8,9,10}; const name[7]={'K','U','N','D','A','N'}; #include<stdio.h> #include<conio.h> void main() { int i; const name[7]={'K','U','N','D','A','N'}; for(i=0;i<7;i++) { printf("%c",name[i]); getch(); }
const type, for instance (const double = 1.1; this you cannot change during run)
1960(independence constitution). Since then,there has been the 1963 republican constitution, the 1975 const., [ the aborted 1989 const., the aborted 1993 const.,] and the currently operating 1999 constitution
If you mean the "general equation of a cone" to be the elliptical cone equation: z = √( (x/a)2 + (y/b)2 ) ... then the function in C to compute this given the proper variables is: double genEqCone(const double x, const double y, const double a, const double b) { const double X_A = (x/a); const double Y_B = (y/b); return sqrt((X_A * X_A) + (Y_B * Y_B)); }
You cannot change the value of a const variable. That's what const means - it is constant. If you are considering "trickery" using pointers and the scanf function, understand that this is not supported, is highly non portable, and may fail, depending on whether or not the implementation places its const data in read only memory. Besides, most modern compilers will not allow you to place a const variable as a non-const argument to a function. Use the language within its defined boundaries.
[OH-]=[acidic medium]. kw /[basic medium]KOH At const temp and pressure Kw/KOH=const.=K1=[H+][In-]/[HIn] pk1 is generally termed as indicator const.
Well, uh, const unsigned int and const signed int..
in stdio.h:extern int printf (const char *fmt, ...);
int printf (const char *fmt, ...)orint scanf (const char *fmt, ...)
int const *p declares a 'p' pointer, that points to a constant integer
You mean this: const double PI = 4*atan(1); Well, it should be either const double PI = 3.14159265358979323846264338327950288 or double PI = 4*atan(1); /* without const */