Write a program that computes the product of two numbers:
ALGORITHM:
ENTER two numbers
Compute the product of P=N1*N2
PRINT P
PROGRAM:
Program Product;
Uses crt;
Var N1,N2:integer;
Product:integer;
Begin
Clrscr;
Writeln(enter two numbers);
Readln(N1,N2);
Product:=N1*N2;
Writeln(The product:product);
Readln;
End.
2. Create a program that computes the difference of two numbers
ALGORITHM:
ENTER TWO NUMBERS
Compute the difference
PRINT D
PROGRAM:
Program difference;
Uses crt;
Var N1,N2: integer;
Difference : integer;
Begin
Clrscr;
Writeln(enter the two numbers);
Readln(D);
D:=N1-N2;
Writeln(‘the difference:difference’)
Readln;
End.
3. Write a program that computes the sum of two
ALGORITHM:
ENTER TWO NUMBERS
Compute the difference
PRINT D
PROGRAM:
Program difference;
Uses crt;
Var N1,N2: integer;
Difference : integer;
Begin
Clrscr;
Writeln(enter the two numbers);
Readln(D);
D:=N1-N2;
Writeln(‘the difference:difference’)
Readln;
End. 1.
SHORT IF THEN ELSE:
2. Create a program that determines If the input age is qualified to vote or not. Qualifying age is 18, If not (else), print” too young!”
Algorithm:
ENTER A
If A>=18 THEN
PRINT ”Qualified to VOTE”
ELSE
PRINT “TOO YOUNG”
PROGRAM:
Program vote;
Uses crt;
Var A:integer;
Begin
Clrscr;
Writeln(enter your age);
Readln(A);
If(A>=18)then
Writeln(qualified to vote)
Else
Writeln(too young);
Readln;
End.
3. Create a program that determines if the input numbers is a magic number (143) which is equivalent to the magic word: “I LOVE YOU”, if it is equivalent, then display the message.”Right” otherwise display the message. ”Wrong”.
Algorithm:
ENTER N
IF N=143 THEN
PRINT “I LOVE YOU”
ELSE
PRINT “WRONG”
PROGRAM:
Program MagicNumber;
Uses crt;
Var N:integer;
Begin
Clrscr;
Writeln(enter your Number);
Readln(N);