Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Objective - Create a program that prints the numbers, but replaces numbers that meet certain criteria. - Work with control structures such as looping

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

- Objective - Create a program that prints the numbers, but replaces numbers that meet certain criteria. - Work with control structures such as looping and if-statements and/or switch-cases. - Related SLO: - Develop properly structured multifile programs with automatic compilation. - Instructions A. Use emacs to create a file named makefile that will automatically compile and build the executable for LastnameFirstname07. c. 1. You can use makefile-char as a template, but be sure to change the file name to makefile and make edits to change all instances of inputchar to LastnameFirstname07. The makefile-char compiles inputchar.c and builds the executable named program. The makefile you are creating for this assignment will need to compile LastnameFirstname07.c and build the executable named program. 2. You may name the executable "program" or some other meaningful name. 3. The name of the makefile must be named makefile. 4. Note: This file should not have a file extension! B. Create a program named LastnameFirstname07.c, that does the following: 1. Note: This program has no user input. 2. Create a for-loop to print the numbers from 1 to 100 , each number on its own line. 3. Modify the loop so that numbers with certain characteristics print a word instead: - For numbers divisible only by 3, print "Spam" instead of the number. - For numbers divisible only by 7, print "Musubi" instead of the number. - For numbers divisible by 3 and 7, print "SpamMusubi" instead of the number. - All other numbers, just print them out. - Use the modulo operator \% to determine if a number is divisible by another number. - For example, to test if a number is divisible by 3 , the condition would be: if (i%3==0 ) - where i represents the number you want to test. 4. After the for-loop, repeat the same process but use a while-loop instead. 5. Add a label above each loop to indicate the kind of loop that was used to accomplish the output. See Example Output for example labels. 6. Be sure to have a program description at the top and in-line comments. 7. Code adheres to the coding standard. 8. Be sure to have read through the assignment policy for this class. Submission Guidelines - Submit your LastnameFirstname07.c and makefile files to the Digital Dropbox. - Be sure to check your hawaii.edu e-mail for confirmation of your submission. - Due Date: Tuesday, Feb. 7 by 11:55pm - Example Output \% make %./program SpamMusubi Algorithm using a for-loop: 1 2 Spam 4 5 Spam Musubi 8 spam 10 11 Spam 13 Musubi Spam 16 17 Spam 80 Spam 82 83 SpamMusubi 85 86 Spam 88 89 Spam Musubi 92 Spam 94 95 Spam 97 Musubi Spam 100 program: inputchar.o gcc inputchar.o -o program inputchar.0: inputchar.c gcc -c inputchar.c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions