write a program in C that prompts the user for today's
date,tomorrow's date and display the results.Use structures
for today's date,tomorrow's date and an array to hold the
days for each month of the year.



write a program in C that prompts the user for today's date,tomorrow's date and display t..

Answer / Honey Agarwal

```cn#include <stdio.h>nnstruct Date {n int day;n int month;n int year;n};nnconst int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};nnvoid getDates(struct Date *today, struct Date *tomorrow) {n printf("Enter today's date (dd mm yyyy): ");n scanf("%d %d %d", &today->day, &today->month, &today->year);n tomorrow->day = today->day + 1;nn if (tomorrow->month == 1 && tomorrow->day > daysInMonth[0]) {n tomorrow->month = 2;n tomorrow->day -= daysInMonth[0];n }n else if (tomorrow->month > 12) {n tomorrow->year++;n tomorrow->month -= 12;n }n}nnvoid displayDate(struct Date date) {n printf("%d/%d/%dn", date.day, date->month, date->year);n}nnint main() {n struct Date today, tomorrow;n getDates(&today, &tomorrow);n printf("Today's date is:");n displayDate(today);n printf("Tomorrow's date is:");n displayDate(tomorrow);n return 0;n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Differentiate between #include<...> and #include '...'

1 Answers  


how to get the starting address of file stored in harddisk through 'C'program.

2 Answers   Siemens,


A stack can be implemented only using array?if not what is used?

3 Answers   InterGlobal,


Explain how do you convert strings to numbers in c?

1 Answers  


What is the purpose of type declarations?

1 Answers  


write a program to read a number and print in words that is in sentence for example 21,219 then output is "twenty one thousand and two hundred nineteen" by using only control flow statements (only loops and switch case )?

1 Answers   TCS,


What is the difference between text and binary modes?

1 Answers  


enum DAY { sunday, monday, tuesday }; enum EDAYS { friday, saturday, sunday }; void main() { int i =0; if( i == sunday) { printf("%d",i); } } what would be the output?

4 Answers   TCS,


can we store values and addresses in the same array? explain

3 Answers   TCS,


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1 Answers  


Explain what is the general form of a c program?

1 Answers  


what is the code for getting the output as * ** ***

5 Answers   Caritor,


Categories