answersLogoWhite

0

#include<iostream>

#include<string>

#include<ctime>

using namespace std;

std::tm input_date()

{

while (true)

{

cout << "Enter date (dd/mm/yyyy): ";

string input;

getline (cin, input);

size_t d, m, y;

int n = sscanf (input.c_str(), "%u/%u/%u", &d, &m, &y);

if (n!=3)

cout << input << " is not a valid date." << endl;

else

{

tm date;

memset (&date, 0, sizeof(tm));

date.tm_isdst = -1;

date.tm_mday = d;

date.tm_mon = m-1;

date.tm_year = y-1900;

return date;

}

}

}

int main()

{

tm date = input_date();

time_t tt = mktime (&date);

date = *localtime(&tt);

switch (date.tm_wday)

{

case (0): std::cout << "Sunday"; break;

case (1): std::cout << "Monday"; break;

case (2): std::cout << "Tuesday"; break;

case (3): std::cout << "Wednesday"; break;

case (4): std::cout << "Thursday"; break;

case (5): std::cout << "Friday"; break;

case (6): std::cout << "Saturday"; break;

}

std::cout << std::endl;

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

What is the program to input name and print pass or fail?

Input "enter name" ;n$ input "enter marks" ; m ifm &gt; 40 then print n$, "pass" else print n$, "fail"


Program to print no divisible by 7?

cls input "enter a no"; num if num mod 14= num then print "no is divisible" else print "not divisible" end if end


C program to print mark sheet of 5 subjects and the number of students is user input?

hhh


Write a program in 'C' language to accept 6 strings as input and print them in lexicographic?

(ab)*b


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Write a program to print whether the letter is vowel or not in BASIC?

vowels$ = "aeiou" CLS PRINT "PROGRAM: Find if letter is a vowel or not" PRINT INPUT "Type a single alphabet letter: (a-z)/and, then, press Enter key"; aLetter$ PRINT PRINT "Letter "; aLetter$; IF INSTR(vowels$, LCASE$(aLetter$)) THEN PRINT " is a vowel." ELSE PRINT " is NOT a vowel." END


How do you prepare a program in basic to display the word and the number of letters in it when is given as input?

10 cls 20 input"enter word";word$ 30 print word$ 40 print len(word$) 50 end this program is for GW BASIC for other BASIC's the line numbers are optional.


How do you write a pseudocode program that commutes and displays a 15 percent tip when you input the price of the meal?

input price calc tip = price*0.15 print tip


Write a QBASIC program to convert a temperature in degrees Fahrenheit to degrees Celsius or vice versa depending on input?

CLS INPUT "Enter degrees in Celsius:";c INPUT "Enter degrees in Fahrenheit:";f a=(c*1.8)+32 b=5/9(f-32) PRINT c;"degree Celsius=" a;"degree Fahrenheit" PRINT f;"degree Fahrenheit=" b;"degree Celsius" end


Write a program that prompts the user to input the length and width of a rectangle and then prints the rectangle's area and perimeter?

PRINT "Give me the rectangle's length.": Input L PRINT "Give me the rectangle's width.": Input W PRINT "The rectangle's area is "; L x W PRINT "The rectangle's perimeter is "; 2 x (L + W) PRINT "You've been a great audience. I'm here til Thursday. Don't forget to tip your waiter. Have a nice day."


What is the meaning of print and input in idle python?

"print" will output a value onto the screen for a user to see. "input" or "raw_input" gets a user's input.


What is stdin stdout and stderr in c?

stdin is short for &quot;standard input.&quot; When you input data into the terminal while the program is running, this is where it goes.stdout is short for &quot;standard output.&quot; This is where all of the data that you print out of your program (via printf(), puts(), etc.) goes. stderr is short for "standard error." This is where you should print your error messages to (via fprintf(), fputs(), etc.).