Source code for C++ program to read length and width of a rectangle and display its area.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len,wth,area;
cout<<" Enter the length:" ;
cin>>len;
cout<<" Enter the breadth:" ;
cin>>wth;
area=len*wth;
cout<<" Area of rectangle:" <<area ;
getch();
}
Source code for Java program to read length and width of a rectangle and display its area.
import java.util.Scanner;
class displayArea
{
public static void main(String []args)
{
int len,wth,area;
Scanner sc=new Scanner(System.in);
System.out.println(" Enter the Length:" );
len=sc.nextInt( );
System.out.println(" Enter the width:" );
wth=sc.nextInt( );
area=len*wth;
System.out.println(" Area of rectangle is :" +area );
}
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len,wth,area;
cout<<" Enter the length:" ;
cin>>len;
cout<<" Enter the breadth:" ;
cin>>wth;
area=len*wth;
cout<<" Area of rectangle:" <<area ;
getch();
}
Source code for Java program to read length and width of a rectangle and display its area.
import java.util.Scanner;
class displayArea
{
public static void main(String []args)
{
int len,wth,area;
Scanner sc=new Scanner(System.in);
System.out.println(" Enter the Length:" );
len=sc.nextInt( );
System.out.println(" Enter the width:" );
wth=sc.nextInt( );
area=len*wth;
System.out.println(" Area of rectangle is :" +area );
}
}
No comments:
Post a Comment