Tuesday 23 October 2012

The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.


using System;
class Program5
{
 public static void Main()
 {
  double l,b,r,A_r,P_r,A_c,C_c;
 Console.Write("Enter length and breadth of a rectangle in cm\n");
 l=Convert.ToDouble(Console.ReadLine());
 b=Convert.ToDouble(Console.ReadLine());
 A_r=l*b;
 P_r=2*(l+b);
 Console.Write("Area of rectangle = {0} sq.cm\nPerimeter of rectangle = {1} cm\n",A_r,P_r);
 Console.Write("Enter radius of circle in cm\n");
 r=Convert.ToDouble(Console.ReadLine());
 A_c=22.0/7*r*r;
 C_c=2*22.0/7*r;
 Console.Write("Area of Circle = {0} sq.cm\nCircumference of circle = {1} cm\n",A_c,C_c);
 }
}

Output:-

No comments:

Post a Comment