#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;
}
Input "enter name" ;n$ input "enter marks" ; m ifm > 40 then print n$, "pass" else print n$, "fail"
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.
input price calc tip = price*0.15 print tip
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
"print" will output a value onto the screen for a user to see. "input" or "raw_input" gets a user's input.
Input "enter name" ;n$ input "enter marks" ; m ifm > 40 then print n$, "pass" else print n$, "fail"
cls input "enter a no"; num if num mod 14= num then print "no is divisible" else print "not divisible" end if end
hhh
(ab)*b
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.
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
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.
input price calc tip = price*0.15 print tip
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
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."
"print" will output a value onto the screen for a user to see. "input" or "raw_input" gets a user's input.
stdin is short for "standard input." When you input data into the terminal while the program is running, this is where it goes.stdout is short for "standard output." 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.).