answersLogoWhite

0

What else can I help you with?

Continue Learning about Math & Arithmetic

What is the c plus plus program to find the area and perimeter of a circle and rectangle?

#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; }


How do you write a c plus plus program to print a hollow square of a given size using asterisks and blanks?

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; }


How do you declare a constant using PHP?

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.


What is the anti derivative of e3x?

anti derivative of ax^n is (a/n+1)x^(n+1) a is a const n is power of variable and answere6x^2


How do you write a c function to produce a table of the numbers from 1 to their squares and their cubes?

#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; }

Related Questions

What is the difference between inline and const?

Everything. "inline" refers to functions, "const" refers to variables.


How do you declare a constant Explain it with a suitable example?

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(); }


What is the prototype of printf function?

The prototype of the printf function is: int printf(const char *format, ...);


In programming what values do not change?

const type, for instance (const double = 1.1; this you cannot change during run)


When did Nigeria first get a Constitution?

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


How do you find the general equation of cone using C language?

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)); }


How can we replace the value of const variable using scanf statement?

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.


How would you read int const p?

int const *p declares a 'p' pointer, that points to a constant integer


What is the full form of printf or scanf?

int printf (const char *fmt, ...)orint scanf (const char *fmt, ...)


What are the different types of integer constants in c language?

Well, uh, const unsigned int and const signed int..


What is the correct abbreviation for construction?

"const."


Where global variable get register?

const