C Program To Add Days To Date

C Program To Add Days To Date. If you are looking for adding days to date program in C, here in this tutorial we will help you to learn how to write a c program to add days to date.

C Program To Add Days To Date

Just copy paste the below source code to add days to date in C compiler to test, how the source code works. Or use this below c program as a reerence and write your own logic. Run and Debug to learn how it works. Happy coding.

C Program To Add Days To Date Source Code

/* C Program to Add Days to Date - AddDaysToDate.C */

#include <time.h>
#include <stdio.h>
int main()
{
 int day = 1;
 imt month = 2; // February
 int year = 2010; // year can not be before 1900
 int days_to_add = 123;
 struct tm tm;
 
 // initialize the structure
 memset(&tm,0,sizeof(struct tm));

 tm.tm_year = year-1900; 
 tm.tm_mon = month-1; // 0 = Jan, 1 = Feb etc
 tm.tm_mday = day;
 tm.tm_hour = 12; // fictious
 tm.tm_mday += days_to_add;
 mktime(&tm);
}

C PROGRAMMING EXAMPLES

  1. C Program to Add Two Fractions
  2. C Program To Reverse A Number
  3. C Program to Find Maximum and Minimum Numbers
  4. C Program to Read a Text File
  5. C Program to Convert Decimal to Hexadecimal
  6. C Program to Convert Decimal to Binary
  7. C Program to Convert Celsius to Fahrenheit
  8. C Program To Find Absolute Value
  9. Ternary Operator Program in C
  10. C Program For Addition Table Using For Loop
  11. Denomination Program in C
  12. C Program to Print Multiplication Table 
  13. C Program Array with Example
  14. Binary Search in C Program Using Recursion
  15. Bubble Sort in C Using Pointers
  16. Bubble Sort Program in C Using Recursion
  17. Bubble Sort Program in C Using Array
  18. Bubble Sort Program in C Using Function
  19. Bubble Sort Program in C Using Linked List
  20. Stack Push Pop Program in C Using Arrays

Leave a Reply

Your email address will not be published. Required fields are marked *