This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

I need a program that will print a square and cubes table. It would like this:

Number Square Cube

1 1 1

Once you get the square, couldn't you get the cube by multiplying the number *square? Or do you have to do a cube?

It should also print out the sum of the squares, the sum of the cubes, how many cubes were greater than 500, a message stating whether or not the sum of the squares exceeded 2,000.

Shouldn't it go something like this?

program SquareCubeTable;

var i, number, square, cube, sumsquare, sumcube: integer;

begin

for i := 1 to 15 do

begin

square := i * i;

cube:= number * square;

I don't know how to align it.

You would do the sum of the square and cubes like this?

begin

sum:= 0;

for i:= 1 to 15 do

sum := i*i + i;

writeln('sum of squares is ', sum)

if sumsquares > 2,000 then

writeln('Sum of squares was over 2,000 ')

begin

sum:= 0;

for I:= 1 to 15 do

sum:= number * square + 1;

writeln('sum of cubes is ', sum)

I don't how do this all in one program.

I wouldn' know about the greater than part

Number Square Cube

1 1 1

Once you get the square, couldn't you get the cube by multiplying the number *square? Or do you have to do a cube?

It should also print out the sum of the squares, the sum of the cubes, how many cubes were greater than 500, a message stating whether or not the sum of the squares exceeded 2,000.

Shouldn't it go something like this?

program SquareCubeTable;

var i, number, square, cube, sumsquare, sumcube: integer;

begin

for i := 1 to 15 do

begin

square := i * i;

cube:= number * square;

I don't know how to align it.

You would do the sum of the square and cubes like this?

begin

sum:= 0;

for i:= 1 to 15 do

sum := i*i + i;

writeln('sum of squares is ', sum)

if sumsquares > 2,000 then

writeln('Sum of squares was over 2,000 ')

begin

sum:= 0;

for I:= 1 to 15 do

sum:= number * square + 1;

writeln('sum of cubes is ', sum)

I don't how do this all in one program.

I wouldn' know about the greater than part

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sumsquare := 0;

sumcube := 0;

cubesgreater := 0;

for i := 1 to 15 do

begin

square := i * i;

cube := i * square;

sumsquare := sumquare + square;

cubesquare := cubesquare + cube;

if (cubesquare > 500) then

inc(cubesgreater);

end;

end.

This will do most of it for you. You need to print out the statements and tidy the code up.

Note that you must initialise your values before you use them.

{

In this program f is an integer variable which is used to format the

output. Formatting the output means much more than just allignment

of output. The expression :f:0 tells comuter(if f=13) to

reserve total length of 13 characters for number and 0 spaces for

numbers after decimal point. 0 because we know that cubes and squares of integers

are never in fractions. Try and see how different outputs come by

changing :f:0. If values of cubes and square grows larger simply

increase the value of f to format perfectly.

}

program square_cube;

uses crt;

var n,bigger_500,f : integer;

cube, square, sumcube, sumsquare : real;

begin

clrscr;

cube := 0; square := 0;

sumcube := 0; sumsquare := 0;

bigger_500 := 0; f := 13;

writeln('Number Square Cube');

for n := 1 to 15 do

begin

square := n * n;

cube := n * square;

sumsquare := sumsquare + square;

sumcube := sumcube + cube;

if cube > 500 then bigger_500 := bigger_500 + 1;

writeln(n:3,square:f:0,cub

end;

writeln('-----------------

writeln('Total',sumsquare:

writeln;

if sumsquare > 2000 then writeln('The sum of squares is greater than 2000.')

else writeln('The sum of squares is not greater then 2000.');

writeln('The number of cubes greater than 500 = ',bigger_500);

writeln;

writeln('Press ENTER to continue.....');

readln;

end.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialprograms won't print either. I've used the 'uses printer' command in all of them.

If so you may have told Windows 95 that you do not print MS-DOs programs and hence Windows won't let the Pascal program print.

Solution. Save output to a text file and then retrieve the file into a wordprocessor program, change font to Courier and print.

uses Printer;

Write(Lst, 'This is output');

This should work. Try it and report back. This is straight out of the TP 5.5 manual and assumes that your printer is connected to your parallel port LPT1.

Pascal

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.