Area and Perimeter of a Rectangle in C++ Program
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float area,perimeter,w,l;
cout<<"Enter Width of Rectancle";
cin>>w;
cout<<"Enter Length of Rectancle";
cin>>l;
area=w*l;
perimeter=2*(l+w);
cout<<" Area of a Rectangle:"<<area;
cout<<" perimeter of a Rectangle:"<<perimeter;
getch();
}
#include<conio.h>
void main()
{
clrscr();
float area,perimeter,w,l;
cout<<"Enter Width of Rectancle";
cin>>w;
cout<<"Enter Length of Rectancle";
cin>>l;
area=w*l;
perimeter=2*(l+w);
cout<<" Area of a Rectangle:"<<area;
cout<<" perimeter of a Rectangle:"<<perimeter;
getch();
}
Area and Perimeter of a Rectangle in Java Program
import java.util.Scanner;
class AP
{
public static void main(String []args)
{
Scanner obj=new Scanner(System.in);
float area,perimeter,w,l;
System.out.print(" Enter Width of Rectancle :");
w=obj.nextFloat();
System.out.print(" Enter Length of Rectancle :");
l=obj.nextFloat();
area=w*l;
perimeter=2*(l+w);
System.out.println(" Area of a Rectangle :" +area);
System.out.println(" perimeter of Rectangle :" +perimeter);
}
}
No comments:
Post a Comment