Write a Modular C Programming code to find out the date of the 256th day of that year
Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the 256th day of the year) during a year in the inclusive range from 1920 to 2700. In calendar systems, February is the only month with a variable amount of days; it has 29 days during a leap year, and 28 days during all other years.
Leap years are either of the following:
-Divisible by 400.
-Divisible by 4 and not divisible by 100.
Given a year, y, find the date of the 256th day of that year according to the calendar during that year. Then print it in the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.
Input Format
Input is y, (year)
Constraints
1920 <= y <= 2700
Output Format
Date in the format dd.mm.yyyy
Sample Input 0
1500
Sample Output 0
Invalid year
Sample Input 1
1947
Sample Output 1
13.09.1947
Refer : C Programming HackerRank all solutions for Loops | Arrays | strings
CODE:
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int year; scanf("%d",&year); if(year>=1920&&year<=2700) { if(year%400==0||(year%4==0&&year%100!=0)) { printf("12.09.%d",year); } else printf("13.09.%d",year); } else printf("Invalid year"); }
OUTPUT
Congratulations, you passed the sample test case. Click the Submit Code button to run your code against all the test cases. Input (stdin) 1500 Your Output (stdout) Invalid year Expected Output Invalid year
Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:
Top 100+ C Programming codes – KLE Technological University