Description
I will attach the homework question. Also, please make sure it’s C language, not C++. Put the answer in C file and zip it.
Assignment 2
Instructions
Include the following pledge as a comment in your code:
/*
* Name: YOUR NAME
* Date: DATE
* WMU Code of Conduct: https://wmich.edu/conduct/code
* PLEDGE: I pledge my honor that I did not violate
* WMU Student Code of Conduct during this exam/quiz/assignment
* and followed all instructions.
*/
Create a separate project for each question.
Follow the “How to Submit Homeworks” document, under eLearning -> Content
-> Preliminaries, to submit your homework correctly.
Question 1
Print the multiplication table of the number
Example Output:
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
(from
to
) using a for or a while loop.
Rubrics
4 point(s) – Correct implementation of loop.
3 point(s) – Correct output.
3 point(s) – No syntax errors.
Question 2
Use scanf() to read in an integer input, n , from the user. Print all the odd numbers from
to
(inclusive).
Example Output:
Enter n: 5
1
3
5
Rubrics
3 point(s) – Correct implementation of scanf() .
2 point(s) – Correct implementation of loop.
2 point(s) – Correct output.
3 point(s) – No syntax errors.
Question 3
User scanf() to read in an integer input between 0 and 24, where the input is the hour of
the day in military time. Print the following for each case:
if input is between
and
(inclusive), then print morning .
if input is between
and
(inclusive), then print afternoon .
if input is between
and
(inclusive), then print evening .
Otherwise, if input is between
and
(inclusive), then print small hours .
Example Output:
Enter time between 0 and 24: 7
morning
——————————Enter time between 0 and 24: 24
evening
Rubrics
2 point(s) – Correct implementation of scanf() .
3 point(s) – Correct implementation of if statement.
2 point(s) – Correct output.
3 point(s) – No syntax errors.
Question 4
Use scanf() to read in an integer, x . Print all the numbers that are divisible by
to
from
(inclusive). You must the mod operator ( % ) to check if a number is divisible by
another or not.
Example Output:
Enter x: 15
3
6
9
12
15
Rubrics
1 point(s) – Correct implementation of scanf() .
2 point(s) – Correct implementation of loop.
2 point(s) – Correct implementation of if statement.
2 point(s) – Correct output.
3 point(s) – No syntax errors.
Purchase answer to see full
attachment