· Exercise # 1: Wite a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996, is day 366, since 1996 is a leap year. A year is a leap year if it is divisible by 4, but not by 100 or If it is divisible by 400. Your program should accept the month, day, and year as integers. You may assume that the entered date is correct, Le. no need for date validation. • Following are some sample runs: • Sample Run 1: Enter date as follows year month day: 1994 1 1 day of the year 1 • Sample Run 2: Enter date as follows year month day: 1996 12 31 day of the year 366

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Answer all

Slide Type Fragment v
· Exercise # 1: Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1,
1994, is day 1. December 31, 1993, is day 365. December 31, 1996, is day 366, since 1996 is a leap year. A year is a leap year if it is divisible by 4, but
not by 100 or if it is divisible by 400. Your program shouid accept the month, day, and year as integers. You may assume that the entered date is correct,
L.e. no need for date validation.
• Following are some sample runs:
• Sample Run 1:
Enter date as follows year month day: 1994 11
day of the year = 1
- Sample Run 2:
Enter date as follows year month day: 1996 12 31
day of the year - 366
Transcribed Image Text:Slide Type Fragment v · Exercise # 1: Write a program that determines the day number (1 to 366) in a year for a date that is provided as input data. As an example, January 1, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996, is day 366, since 1996 is a leap year. A year is a leap year if it is divisible by 4, but not by 100 or if it is divisible by 400. Your program shouid accept the month, day, and year as integers. You may assume that the entered date is correct, L.e. no need for date validation. • Following are some sample runs: • Sample Run 1: Enter date as follows year month day: 1994 11 day of the year = 1 - Sample Run 2: Enter date as follows year month day: 1996 12 31 day of the year - 366
• Exercise # 2 Write a C program segment that computes 1 + 2+ 3+... +(n - 1) + n, where n is a positive integer value greater than 1. Assume that
you enter an integer, but make sure that you validate that it is a positive integer that is greater than 1. Follow the loop body with an if statement that
compares this value to at and displays a message that indicates whether the values are the same or different. What message do you think will be
displayed?
• Following are two sample runs:
• Sample Run 1:
Enter an integer value greater than 1 : 5
sum of numbers from 1 to 5 = 15
Sample Run 2:
Enter an integer value greater than 1: e
krong input try again
Enter an integer value greater than 1: -5
irong input try again
Enter an integer value greater than 1: 1
irong input try again
Enter an integer value greater than 1 : 20
sum of numbers from 1 to 20 = 210
Slide Type Fragment
* Exercise # 2 - Source Code /
Slide Type Side
• Exercise # 3 Write nests of loops that cause the following output to be displayed
0 12
e 123
0 123 4
0 123 45
0 123 4
0 123
0 1 2
0 1
Transcribed Image Text:• Exercise # 2 Write a C program segment that computes 1 + 2+ 3+... +(n - 1) + n, where n is a positive integer value greater than 1. Assume that you enter an integer, but make sure that you validate that it is a positive integer that is greater than 1. Follow the loop body with an if statement that compares this value to at and displays a message that indicates whether the values are the same or different. What message do you think will be displayed? • Following are two sample runs: • Sample Run 1: Enter an integer value greater than 1 : 5 sum of numbers from 1 to 5 = 15 Sample Run 2: Enter an integer value greater than 1: e krong input try again Enter an integer value greater than 1: -5 irong input try again Enter an integer value greater than 1: 1 irong input try again Enter an integer value greater than 1 : 20 sum of numbers from 1 to 20 = 210 Slide Type Fragment * Exercise # 2 - Source Code / Slide Type Side • Exercise # 3 Write nests of loops that cause the following output to be displayed 0 12 e 123 0 123 4 0 123 45 0 123 4 0 123 0 1 2 0 1
Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY