Slip 14 - A) Write a C++ program to accept radius of a Circle. Calculate and display diameter, circumference as well as area of a Circle. (Use Inline function).

 Solution:

#include<iostream.h>

#include<conio.h>

 inline float diameter(float r)

{

return(r /2);

}

inline float circlearea(float r)

{

return(3.14*r*r);

}

inline float circumference(float r)

{

return(3.14*2*r);

}

int main()

{

float radius;

clrscr();

 cout<<"\n\nEnter the radius of the circle:";

cin>>radius;

cout<<"\nDiameter of Circle:"<< diameter(radius);

cout<<"\nArea of Circle:"<< circlearea (radius);

cout<<"\nCircumference of Circle:"<< circumference(radius);

getch();

return 0;

 }

Post a Comment

0 Comments