home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
msdos
/
turbo_c
/
trbocsrc.arc
/
SUMSQRES.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-02-01
|
866b
|
34 lines
/* Chapter 5 - Program 1 */
int sum; /* This is a global variable */
main()
{
int index;
header(); /* This calls the function named header */
for (index = 1;index <= 7;index++)
square(index); /* This calls the square function */
ending(); /* This calls the ending function */
}
header() /* This is the function named header */
{
sum = 0; /* Initialize the variable "sum" */
printf("This is the header for the square program\n\n");
}
square(number) /* This is the square function */
int number;
{
int numsq;
numsq = number * number; /* This produces the square */
sum += numsq;
printf("The square of %d is %d\n",number,numsq);
}
ending() /* This is the ending function */
{
printf("\nThe sum of the squares is %d\n",sum);
}