For all of these questions, you are not allowed to use the following keywords in your solution: while, do, for. No credit will be given if this rule is violated.
Write a simple program that asks the user to enter an integer. If the integer is between 32 to 126 inclusive, it is a valid integer; else it is an invalid integer.
$ ./lab2q1 Enter an integer (32-126): 56 You have entered a valid integer. $ ./lab2q1 Enter an integer (32-126): 31 You have entered an invalid integer. $ ./lab2q1 Enter an integer (32-126): 310 You have entered an invalid integer. $
Write a program that asks the user to enter the ASCII value (from 32 to 126 inclusive, display error message for invalid integers) of a character. Display the actual character and determine the results of each of the following functions on the character: isupper, islower, isalpha, isdigit, isalnum, ispunct, isspace. If the function returns true, print the return value.
Assuming that the name of the executable file is lab2q2, sample run(s) of the program are shown below. User input is denoted in bold.
$ ./lab2q2 Enter an integer (32-126): 127 You have entered an invalid integer. $ ./lab2q2 Enter an integer (32-126): 68 Character with ASCII value 68 is: "D" isupper is true, returns 1 isalpha is true, returns 1 isalnum is true, returns 1 $ ./lab2q2 Enter an integer (32-126): 33 Character with ASCII value 33 is: "!" ispunct is true, returns 16 $ ./lab2q2 Enter an integer (32-126): 55 Character with ASCII value 55 is: "7" isdigit is true, returns 4 isalnum is true, returns 4 $
A year that is not divisible by four is not a leap year.
A year that is divisible by four and not divisible by 100 is a leap
year.
A year that is divisible by 400 is a leap year.
Write a program that determines if the year entered by the user is a leap year.
Assuming that the name of the executable file is lab2q3, sample run(s) of the program are shown below. User input is denoted in bold.
$ ./lab2q3 Enter year: 1987 1987 is not a leap year. $ ./lab2q3 Enter year: 2008 2008 is a leap year. $ ./lab2q3 Enter year: 2100 2100 is not a leap year. $ ./lab2q3 Enter year: 2000 2000 is a leap year. $
A total of 23 different hosts have accessed this document in the last 444 days; your host, nsrp-source.comp.nus.edu.sg, has accessed it 6 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.