CMSC 104, Spring 2003
Project 3
Due Date:
Midnight, Tuesday March 18
Note: No late projects will be accepted.
Point Value:
This project is worth 25 points.
Objectives:
- To learn to use the gcc compiler
- To become familiar with syntax error messages generated by the gcc
compiler
Assignment:
The assignment is as follows:
The Program:
/**************************************************************
** Filename: proj3.c
** Author: put your name here
** Date Written: 3/11/03
** Section: 0301
** E-mail: put your UMBC e-mail address here
** Description: This program asks the user to enter integers,
** one at a time, until the user enters a zero.
** The largest integer is computed and displayed.
***************************************************************/
#include
int main()
{
int number; /* integer entered by the user */
int largest; /* largest entered read */
/* Prompt the user for an integer and read it */
/* Initialize the largest integer */
printf("Please input an integer or 0 (zero) to stop: ");
scanf("%d", &number);
largest = number;
/* Continue to prompt and read until a zero is read */
/* Keep track of the largest integer entered */
while (number != 0) {
if (largest < number) {
largest = number;
}
printf("Please input an integer or 0 (zero) to stop: ");
scanf("%d", &number);
}
/* Display the largest integer entered */
printf("\nThe largest integer entered was %d.\n", largest);
return 0;
}