Method-1:
=================
Suppose rectangle have length and breadth .so area of rectangle is multiplication of length and width.
Input-length=20 meters and width=10 meters
Output-200 meter square
Operation- area of rectangle=length*width
Code-
SQL> set serveroutput on;
SQL> declare
2 length number;
3 width number;
4 Begin
5 length :=20;
6 width :=10;
7 Dbms_output.put_line('Area of the Rectangle='||length*width);
8 End;
9 /
Area of the Rectangle=200
PL/SQL procedure successfully completed.
========================================================================
Method-2:
=======================
Input-Take two variables length and width and store the result into third variable result.
Output- Area of the rectangle
Operation- result=length*width
SQL> declare
2 length number;
3 width number;
4 result number;
5 Begin
6 length :=20;
7 width :=10;
8 result:=length*width;
9 Dbms_output.put_line('Area of the Rectangle='||result);
10 End;
11 /
Area of the Rectangle=200
PL/SQL procedure successfully completed.
SQL>
===============================================================
Method-3:
====================
Input-Ask user to enter two number length and width and store the result into third variable rec_area.
Output- rec_area
Operation-Area of rectangle
Code-
SQL> declare
2 length number;
3 width number;
4 rec_area number;
5 Begin
6 length :=&length ;
7 width :=&width;
8 rec_area :=length*width;
9
10 Dbms_output.put_line('Area of the Rectangle='||rec_area);
11 End;
12 /
Enter value for length: 20
old 6: length :=&length ;
new 6: length :=20 ;
Enter value for width: 5
old 7: width :=&width;
new 7: width :=5;
Area of the Rectangle=100
PL/SQL procedure successfully completed.
SQL>
=================
Suppose rectangle have length and breadth .so area of rectangle is multiplication of length and width.
Input-length=20 meters and width=10 meters
Output-200 meter square
Operation- area of rectangle=length*width
Code-
SQL> set serveroutput on;
SQL> declare
2 length number;
3 width number;
4 Begin
5 length :=20;
6 width :=10;
7 Dbms_output.put_line('Area of the Rectangle='||length*width);
8 End;
9 /
Area of the Rectangle=200
PL/SQL procedure successfully completed.
========================================================================
Method-2:
=======================
Input-Take two variables length and width and store the result into third variable result.
Output- Area of the rectangle
Operation- result=length*width
SQL> declare
2 length number;
3 width number;
4 result number;
5 Begin
6 length :=20;
7 width :=10;
8 result:=length*width;
9 Dbms_output.put_line('Area of the Rectangle='||result);
10 End;
11 /
Area of the Rectangle=200
PL/SQL procedure successfully completed.
SQL>
===============================================================
Method-3:
====================
Input-Ask user to enter two number length and width and store the result into third variable rec_area.
Output- rec_area
Operation-Area of rectangle
Code-
SQL> declare
2 length number;
3 width number;
4 rec_area number;
5 Begin
6 length :=&length ;
7 width :=&width;
8 rec_area :=length*width;
9
10 Dbms_output.put_line('Area of the Rectangle='||rec_area);
11 End;
12 /
Enter value for length: 20
old 6: length :=&length ;
new 6: length :=20 ;
Enter value for width: 5
old 7: width :=&width;
new 7: width :=5;
Area of the Rectangle=100
PL/SQL procedure successfully completed.
SQL>
Good job
ReplyDelete