Showing posts with label days. Show all posts
Showing posts with label days. Show all posts

Saturday, August 9, 2014

Program to check for a leap year.

Simple C program to check whether a year is leap year or not. If you have any doubts, please let me know.

#include<stdio.h> void main() { int num; printf ("enter number"); scanf ("%d",&num); if(num%4==0&&num%100!=0)||(num%400==0) { printf ("leap year"); } else { printf ("no"); } }

Program for counting years, weeks and days.

Simple C program for counting the number of years, weeks and days. If you have any doubts, let me know


#include<stdio.h> main() { int c,year,x,week,day; printf("enter no of days"); scanf("%d",&c); year=c/365; x=c%365; week=x/7; day=x%7; printf("YEAR %d",year); printf("WEEK %d",week); printf("DAY %d",day); }