Mail Archives: djgpp/2003/11/09/16:15:48
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
Message-ID: | <3FAEA379.C6027413@yahoo.co.uk>
|
Date: | Sun, 09 Nov 2003 20:28:41 +0000
|
From: | "J. Wesolowski" <lutnicx AT yahoo DOT co DOT uk>
|
X-Mailer: | Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i586)
|
X-Accept-Language: | pl, en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: problem with incude file - cont.
|
References: | <3fac20e0_3 AT mk-nntp-1 DOT news DOT uk DOT worldonline DOT com>
|
NNTP-Posting-Host: | ppp-1-74.lond-b-4.access.uk.tiscali.com
|
X-Trace: | 9 Nov 2003 21:07:19 GMT, ppp-1-74.lond-b-4.access.uk.tiscali.com
|
Lines: | 190
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
The only reason why I'm trying to show you the content of include file is because
maybe something went wrong during instalation. I looked through my code
carefully, as carefully as a beginner can, and I coudn't find anything.... I
compiled it with a command
gcc week1.c -o week1.exe (-Wall)
under Win98 and Linux all with similar errors.
Below I include all 120 lines, hoping that you can exuse me.
JW
------------Start of the code--------------
/* Program Name: week1.c */
/* Program to enter the ages and incomes of up */
/* to 100 people. The program prints a report */
/* based on the numbers entered. */
/*----------------------------------------------------------------*/
/*---------------------*/
/* included files */
/*---------------------*/
#include <stdio.h>
/*---------------------*/
/* defined constants */
/*---------------------*/
#define MAX 100
#define YES 1
#define NO 0
/*---------------------*/
/* variables */
/*---------------------*/
long income[MAX]; /* <- to hold incomes */
int month[MAX], day[MAX], year[MAX]; /* <- to hold birthdays */
int x, y, ctr; /* <- for counters */
int cont; /* <- for program control */
long month_total, grand_total; /* <- for totals */
/*---------------------*/
/* function prototypes */
/*---------------------*/
void main(void);
int display_instructions(void);
void get_data(void);
void display_report(void);
int continue_function(void);
/*----------------------*/
/* start of program */
/*----------------------*/
void main(void)
{
cont = diplay_instructions();
if ( cont == YES )
{
get_data();
display_report();
}
else
printf( "\nProgram aborted by user!\n\n");
}
/*---------------------------------------------------------------*
* Function: display_instructions() *
* Purpose: this function displays information on how to *
* use this program and asks the user to enter 0 *
* to quit, or 1 to continue. *
* Returns: NO - if the user enters O *
* YES - if the user enters any number other than 0 *
*---------------------------------------------------------------*/
int display_instructions(void)
{
printf("\n\n");
printf("\nThis program enables you to enter up to 99 people\'s ");
printf("\nincomes and birthdays. I then prints the incomes by ");
printf("\nmonth along with the overall income and overall average.");
printf("\n");
cont = continue_function();
return( cont );
}
/*----------------------------------------------------------------*
* Function: get_data() *
* Purpose: This function gets the data from the user. It *
* continuse to get data until either 100 people are *
* entered, or until the user enters 0 for the month.*
* Returns: nothing *
* Notes: This allows 0/0/0 to be entered for birthdays in *
* case the user is unsure. It also allows for 31 *
* days in each month. *
*----------------------------------------------------------------*/
void get_data(void)
{
for( cont = YES, ctr = 0; ctr < MAX && cont == YES; ctr++ )
{
printf("\nEnter information for Person %d.", ctr+1 );
printf("\n\tEnter Birthday: ");
do
{
printf("\n\tMonth (0 - 12): ");
scanf("%d", &month[ctr]);
}while ( month[ctr] < 0 || month[ctr] > 12 );
do
{
printf("\n\tDay (0 - 31): ");
scanf("%d", &day[ctr]);
}while ( day[ctr] < 0 || day[ctr] > 31 );
do
{
printf("\n\tYear (0 - 2003): ");
scanf("%d", &year[ctr]);
}while ( year[ctr] < 0 || year[ctr] > 2003 );
printf("\nEnter yearly income (in whole pounds): ");
scanf("%ld", &income[ctr]);
cont = continue_function();
}
/* ctr equals the number of people that were entered. */
}
/*------------------------------------------------------------*
* Function: display_report() *
* Purpose: This function displays a report to the screen *
* Returns: nothing *
* Notes: More information could be printed. *
*------------------------------------------------------------*/
void display_report()
{
grand_total = 0;
printf("\n\n\n"); /* <- skip a few lines */
printf("\n SALARY SUMMARY");
printf("\n ==============");
for( x = 0; x <= 12; x++) /* <- for each month, including 0 */
{
month_total = 0;
for( y = 0; y < ctr; y++ )
{
if( month[y] == x )
month_total += income[y];
}
printf("\nTotal for month %d is %ld", x, month_total);
grand_total += month_total;
}
printf("\n\nReport totals:");
printf("\nTotal income is %ld", grand_total);
printf("\nAverage income is %ld", grand_total/ctr);
printf("\n\n* * * End of Report * * *");
}
/*-------------------------------------------------------------------*
* Function: continue_function() *
* Purpose: This function asks the user if they wish to continue.*
* Returns: YES - if the user wishes to continue *
* NO - if the user wishes to quit *
*-------------------------------------------------------------------*/
int continue_function( void )
{
printf("\n\nDo you wish to continue? (0=NO/1=YES): ");
scanf( "%d", &x );
while( x < 0 || x > 1 )
{
printf("\n%d is invalid!", x);
printf("\nPlease enter 0 to Quit or 1 to Continue: ");
scanf( "%d", &x);
}
if( x == 0 )
return(NO);
else
return(YES);
}
------------End of the code----------------
- Raw text -