/*to find the area of a circle*/
#include<stdio.h> #include<conio.h> main()
{
int r;
float a;
print f ("Enter r value \n");
scan f ("%d", &r);
a=3.14*r*r;
print f("area=%f",a);
}
Chat with our AI personalities
#include<assert.h>
typedef struct rect_t {
int width;
int height;
} rect;
int area (rect* r) {
if (r==NULL) return 0;
return r->width * r->height;
}
int main (void) {
rect r;
int a;
r.width = 10;
r.height = 5;
a = area (&r);
assert (a==50);
return 0;
}
double a,b,c,s,area;
double *parea = &area;
s=(a+b+c)/2;
*parea = sqrt (s*(s-a)*(s-b)*(s-c))
int radius = 2; int output; radius = radius * 2; output = radius * Math.PI; Console.WriteLine(output);
By using that one thing.
// macro definitions: #define PI 3.14159265358979323846 #define CIRCUMFERENCE(radius) (2. * (radius) * PI) // use this as in CIRCUMFERENCE(21.34)
#include<stdio.h> main() { int r; float area; clrscr(); printf("enter the value of r\n"); scanf("%d",&r); area=3.142*r*r; printf("area of circle=%f\n",area); getch(); }
2. Write a program using switch statement that reads a character representing a geometrical figure, then asks the user to enter the required data (ex. Radius for a circle, length and height for a rectangle, etc. ...) . The program should then print the area and circumference.Figures are: circle(c), square(s), rectangle(r), triangle (t).