Sale!

Assignment 8 GCD program

$30.00

Category:
Rate this product

CMPS 12L
Introduction to Programming
Lab Assignment 8
In this assignment you will write another C program that emulates the GCD program you wrote for pa3.
Begin by reviewing the specifications for that project and your solution to it. Your task is to write a C
program that operates in the same way, i.e. same prompts, same input and same output. However, the
requirements for this program are relaxed somewhat from those in pa3 in that it is not necessary to filter
out all types of bad input.
Design your program to respond to string inputs by printing
Please enter a positive integer:
as specified in pa3, then scan for another integer. Respond similarly to integer input that is negative or
zero. It is not necessary to react to double inputs according to the pa3 specifications however. Thus you
may assume that things like “25.78” will not be used as input to your program. Everything you need to
do this was explained in the lab7 project description. In particular, review the explanation of the
scanf() function given in that document before you begin this program. A sample session follows.
% GCD
Enter a positive integer: sldkfj
Please enter a positive integer: -56
Please enter a positive integer: 56
Enter another positive integer: sldkjfdlk
Please enter a positive integer: -25
Please enter a positive integer: 25
The GCD of 56 and 25 is 1
%
Recall the CheckInput sequence of examples in Java whose purpose was to learn how to filter input from
standard input. A similar sequence of examples will be posted under Examples/lab8 on the class
webpage. Study these carefully to learn how to read and discard non-numeric string input.
Call your program GCD.c and write a Makefile that creates an executable file called GCD. Include a
clean utility with the Makefile that deletes the executable. Submit both files to the assignment name
lab8.

Reviews

There are no reviews yet.

Be the first to review “Assignment 8 GCD program”

Your email address will not be published. Required fields are marked *

Scroll to Top