PL SQL - Largest of 3 numbers

-- Largest among three numbers using PL SQL

declare
a number(10);
b number(10);
c number(10);
begin
a:=&a;
b:=&b;
c:=&c;
if a>b and a>c then        -- checking if a is the largest.
dbms_output.put_line(chr(10)||a||' is largest');
else if b>c then   -- checking if b is the largest.
dbms_output.put_line(chr(10)||b||' is largest');
else    -- c is largest.
dbms_output.put_line(chr(10)||c||' is largest');
end if;
end if;
end;
/

Output


PL SQL largest among 3 numbers

PL SQL - Area of Circle

-- This PL SQL program finds the area of a circle, whose radius is given as input.


declare
a number(10,2);
pi constant number(10,2):=3.14;
r number(10);
begin
r:=&r;
a:=pi*r*r;  -- calculating the area of circle
dbms_output.put_line('area='||a);
end;

Output


pl sql area of circle


PL SQL program to print multiplication table for a number

-- This program prints the multiplication table for any number, the number and the limit should be given as input.

declare
n number(5);
i number(2);
m number(5);
limit number(5);
begin
i:=1;
n:=&n;  -- The number for which multiplication table should be printed.
limit:=&l;  -- This specifies the limit of the table.
dbms_output.put_line('Multiplication table for '|| n);
for i in 1..limit
loop
m:=n*i;
dbms_output.put_line(n||'*'||i||'='||m);
end loop;
end;

Output

Multiplication table PL SQL




PL SQL - sum of numbers from 1 to 100

-- This PL SQL program is used to find the sum of first 100 numbers.


declare
i number(10);
n number(10);
begin
n:=0;
i:=1;
while i<100
loop
n:=n+i;
i:=i+1;
end loop;
dbms_output.put_line('Sum is:'||n);
end;

Output
sum of first 100 PL SQL

C program to send values 00 to FF to port P1 (8051)

//send values 00 to FF to port P1 in c using Kiel for 8051 microcontroller
#include <reg51.h>
void main(void)
{
unsigned char c;
for (c=0;c<=255;c++)
P1=c;
}

C program to print square and square root

// Printing square and square root using c program
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i=0,sqr;
float sq;
clrscr();
printf("Value   Square Root   Square");
while(i<=100)
{
printf("\n");
sq=sqrt(i);
sqr=i*i;
printf("%d\t%f\t%d",i,sq,sqr);
i=i+10;
}
getch();
}

Output

c program square root