Word Online . (1) Dil Diyan Gallan . × × delab/jsp/core_dhtmljsp?# WORK AREA Day
ID: 3723870 • Letter: W
Question
Word Online . (1) Dil Diyan Gallan . × × delab/jsp/core_dhtmljsp?# WORK AREA Days In A Year (no if statement) Write a program named DaysInYearNoIF that reads an integer representing a year. (In this case there is no prompt from the program.) The program prints out the number of days in that year (366 if the year is a leap year, 365 otherwise) CONSTRAINT: Nowhere in the program is an if statement used REMINDER: the program's output is. shown here in bold; the user's data entry is shown here in italics. Sample Interactive Run 1: 2015 365 days Sample Interactive Run 2: 1992 366 days 1 of 1: Mon Mar 05 2018 12:17:08 GMT-0500 (Eastern Standard Time SUBMIT 1 Type your solution here...Explanation / Answer
Hi,
Below is the C++ code-
#include<stdio.h>
int main()
{
int year;
scanf("%d",&year);
(((year%100)==0) ? ((year%400)==0 ? printf("366 days") : printf("365 days")) : (((year%4)==0) ? printf("366 days") : printf("365 days")));
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.