Question 1:
1)
bool checkLeapYear(int year) {
return year % 4 == 0;
}


2)
int sumOfNumbers(int number) {
number--;
return number * (number + 1) / 2;
}

Question 2:
#include <stdio.h>
#include <stdbool.h>
#define MAX 50
char stack[MAX];
char queue[MAX];
int stackTop = -1;
int queueFront = 0;
int queueRear = 0;
void stackPush(char c) {
stackTop++;
stack[stackTop] = c;
}
char getStackTop() {
return stack[stackTop];
}
void stackPop() {
stack[stackTop] = '\0';
stackTop--;
}
bool stackEmpty() {
return stackTop == -1;
}
void queuePush(char c) {
queue[queueRear] = c;
queueRear++;
}
char getQueueFront() {
return queue[queueFront];
}
void queuePop() {
queue[queueFront] = '\0';
queueFront++;
}
bool isPalindrome(char string[MAX], int size) {
for (int i = 0; i < size; i++) {
stackPush(string[i]);
queuePush(string[i]);
}
while (!stackEmpty()) {
if (getStackTop() != getQueueFront())
return false;
stackPop();
queuePop();
}
return true;
}


comment down for any queries
please give a thumbs up
Assignment 1 Year 2 ICTEDU term 1 2019 For question 1 and 2 the report should...
[30 points] Question 3 A palindrome is a string that reads identical forwards and backwards Examples include abba, abcba, a1b1b1a, houstonnotsuoh etc Your task is to write a program that reads an input string prints that string, and then prints one of the following as appropriate: Is a Palindrome or Nota Palindrome I user response is input - racecar, the above program should print гacecar Is a Palindrome If user response is input = hello, the above program should print...
Write a function palcheck (char word II) which takes a C-style string word (or a C++ string word if you wish) and returns or false depending on whether or not the string is a palindrome. (A palindrome is a string which reads the same backwards and forwards. Some classic example of palindromes are radar, racecar, toot, deed, bib, civic, redder and madam.) Use your function from part (a) in a complete C++ program which, for each small letter 'a' through...
1.) Write a recursive function named isPalindrome that will take a single string as an argument and determine if the argument is a palindrome. The function must return True if the argument is a palindrome, False otherwise. Recall that any string is a palindrome if its first and last characters are the same and the rest of it is also a palindrome (therefore, a single character is a palindrome): 2.) Consider a text file named samplestrings.txt that contains a collection...
Complete task using python code
From definitions file:
month = ‘February’
year = 1200
Problem 2: Leap Years (2 Points) Your task is to write a program that takes in both a month and year (defined in the definitions file) and outputs the number of days for that month. It should take into account whether the year is a leap year or not. The resulting number of days in a given month/year combo is to be assigned to the variable...
PLEASE do the following problem in C++ with the screenshot of the output. THANKS! There are 3 parts. (1) Write a C++ program to check an input string by user is palindrome or not. (2) Write a program to check whether the year provided by a user is a leap year or not. (3) Write a program which accepts days as integer and display total number of years, months and days in it. For example : If user input as...
Python Programming Task 2: Leap Years Part A - Is this a leap year? Write a function is leap year(year) that calculates whether a given (CE) year is a leap year. The function must: • take one argument: a positive integer representing a year (assumed to be CE) • return True if that year was a leap year; return False if not NOTE: all years that are divisible by four are leap years, unless they are also divisible by 100,...
Instructions ASSIGNMENT 2 is at bottom of the question. Very simple program and these intructions are only to modify it slightly, should only take about 10 minutes says my proffessor. Your file should be named “Main.java”. Ask the user how many year inputs he wants to check - an integer. Assume that the user always gives an input which is between 1 and 5 (inclusive). Next, ask the user for K number of year inputs where K = the number...
Your program must prompt the user to enter a string. The program must then test the string entered by the user to determine whether it is a palindrome. A palindrome is a string that reads the same backwards and forwards, such as "radar", "racecar", and "able was I ere I saw elba". It is customary to ignore spaces, punctuation, and capitalization when looking for palindromes. For example, "A man, a plan, a canal. Panama!" is considered to be a palindrome....