Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment. function isEven(num){ if(MISSING CONDITION){ return true; } else { return false;
Q: The ispunc(x) function is applicable to both int data type. True False
A: The ispunct() function determines whether or not a given character is a punctuation mark. ispunct()…
Q: How do I set a boolean hasDigit to true if string userInput contains a digit? bool hasDigit; string…
A: Please find the answer below :
Q: hat are the values of i and j after the following code has been executed and i and j are both set to…
A: Here is the Solution. GIVEN:- it is given that i and j are both set to 15 before the code is…
Q: Given the code: void d(int n) { if(n<2) { cout << n < " "; return; } H. cout << n << " ": d(n/3); 1.…
A: Given:
Q: Given the code: void c(int n) { if(n<2) { cout << n <<""; return; } c(n/2); cout << n << " "; } 11.…
A: C++ program given and n =12
Q: Evaluate the following postfix expression. 3 7 8 * +
A: According to the Question below the solution:
Q: Write a function called show_palindrome that takes a number as an argument and then returns a…
A: To solve two method one should aware of list and string data type And for loop , converting int to…
Q: Fill-In Blanks of the following question: Postfix 2 3 4 * 5+ - is equal to...................
A: Please refer below for your reference: The given postfix expression is : 2 ,3,4,*,5,+,-
Q: Stream manipulator showpoint forces floating-point values to print with the default sixdigits of…
A: Here have to determine about stream manipulators for floating point.
Q: The special case return value that will terminate the following code is ____________________. int…
A: Returning the value 1 is the terminating point for this recursion.
Q: c++, Print out all composite numbers from 2 to 50 using a loop. Within the loop, you must call a…
A: The asked C++ program is coded in the next step with explanatory comments.
Q: When does this code segment return true? a. When all int values in nums are greater than or equal to…
A: The given problem has a for loop segment that analysis the array elements. The requirement is to…
Q: Given what is supposed to be typed and what is actually typed, write a function that returns the…
A: Coded using JavaScript.
Q: c# Write program that asks to enter an x numbers and sum the even numbers and odd numbers…
A: Write program that asks to enter an x numbers and sum the even numbers and odd numbers separately…
Q: What is the terminating condition in the following code? int Sum(int n) { if(n < 2)…
A: Given: What is the terminating condition in the following code? int Sum(int n) { if(n < 2)…
Q: complete the function that will return the multipication of 3 given numbers - a,b,c. def…
A: Logic: Product of three numbers is multiplication of three numbers and then store in number After…
Q: What is the output of the following code segment? int x = 5; if (x = 2) cout << "This is true!" <<…
A: The given code is : int x=5; if(x=2) cout<< "This is true" << endl; else…
Q: Programming C++ full question: Write a program that prints the multiplication table but inserts a…
A: Given: Write a program that prints the multiplication table but inserts a randomly generated…
Q: Suppose the state of the argument segment is as follows: argument 0 10 1 2 What will be…
A: Solution of the given question is:-
Q: What does this function using to? * int max(int a , int b) { if(a > b) return a; else return b; }…
A: The given piece of code is - int max(int a, int b){if(a>b) return a;elsereturn b;}
Q: The following function has errors. Locate as many errors as you can. void area(int length = 30, int…
A: Correction Explanation: The argument length should be declared inside the function body or at the…
Q: Given the following mystery function, what is the output if the number passed to the function is 7:…
A: We are given a recursive function code in c++ which is called with value 7. I have answered the…
Q: Write a code to check if it is a strong number or not
A: As the coding language is not given so i am doing this code in C language: #include…
Q: Which integer data types can only hold non-negative values?
A: Given:- Which integer data types can only hold non-negative values?
Q: Create a function that takes a string as an argument and returns true if each letter in the string…
A: In this problem, we need to design a javascript program. Input - one string as an argument output -…
Q: In the C++ programming language, the function can call itself True O False
A:
Q: Evaluate the given expressions. All values are on integer format. int a-10.b=11.c=16.d=0.e=2:…
A: Correct Answer= -12 int a=10,b=11,c=16,d=0,e=2; Here is step by step solution !((a*b!=c) ||…
Q: What will be output by the above code segment ?
A: #include <iostream> using namespace std; int main(void){ int m=1,n=2; //initialize m…
Q: al tHe values a to and returns the result to main addltTogether (int a, int b) { int total = 0; %3D…
A: Here have to determine about code for get total between 2 numbers.
Q: * Q: Find the value of main () { int x, y, z,M; x=0; y=1;z=1; M=++x || ++y && ++z; cout<<"M="<<M; }
A: We have to find value of M in given code C++ Code #include <iostream> using namespace std;…
Q: Question 5: generate a sequence of numbers that the result of dividing them by four will be 3 and…
A: #include <bits/stdc++.h>using namespace std; int main(){ for (int i = 1; i < 100; i++) {…
Q: Rearrange the code, all necessary code is already listed
A: from _collections import defaultdictdef wiz_study_length(prereq_list,final = 'WIZ90001'):…
Q: The program segment has errors. Find as many as you can. // This code should add two user-entered…
A: Step 1:- Program:- #include <iostream>using namespace std;int main(){int num1, num2; char…
Q: 3.17.1: String with digit. Set hasDigit to true if the 3-character passCode contains a digit.…
A: To check whether a character is digit or not we can use the following statement if (passCode[i]…
Q: Create a function that will test if a string is a valid PIN or not via a regular expression. A valid…
A: Algorithm - Take one string as input. Now use the below logic pin.matches("^(\\d{4}|\\d{6})$");…
Q: 1. What is the output of the following code segment? n = 1; while (n <= 5) cout << n << ' '; n++;
A: Given program (with open while loop) is written with comments below as complete program for…
Q: 1. prints all multiples of 5 between 5 and 50 inclusive and then 2. reads a number from the user and…
A: Code and output is in step2.
Q: int answer ; int number4 = 15, number8 = 10, number10 = 2; answer = ( number4 * number8…
A: Solution given below : Explanation int answer; int number4 = 15, number8 = 10 , number10=2;…
Q: Create a function that takes a string as an argument and returns true if each letter in the string…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: Complete the convert() function that casts the parameter from a float to an integer and returns the…
A: Given: To write a function convert () that casts the float to int and then return the result.
Q: nine the value of x and y at the indicated lines when parameter passing is pass-by-value.…
A: In pass by value, the value of variable passed is copied in a different location. Thus we create two…
Q: Use the algorithm described above to evaluate the following postfix expression: 5 6 2 + • 2 11 * 5 %…
A: The Pseudocode says when there is an operand which is number, they are pushed on top of stack and…
Q: Write a function that parses a binary number into a hex number.The function header is:def…
A: Function that parses a binary number into a hex number. The function header is: def…
Q: The special case return value that will terminate the following code i
A: The special case return value that will terminate the following code is ____________________. int…
Q: Nhat is the output from the following code segment? int point = 1; while ( point ! = 13) { cout <<…
A: Answer to the above question is in step2.
Q: int i, n; // initialize first and second terms int t1 = 0, t2 = 1; // initialize the next term (3rd…
A: Converting following c program into MIPS instructions
Q: Write a fiunction to find the largest integer among three integers entered by the user in the main…
A: Since the programming language is not mentioned , I have done the code in C++. Algorithm : max3…
Q: Q1) A- Write a program to find the result of the sequence 1 (y + 1! 3y 1 (y +3 + 3! 5y y +M M!\(M +…
A: 1. A. Since no programming language is mentioned, I am using python. Algorithm: Start Read m, y…
Q: Write a program that prompts the user to enter twostrings and displays the largest common prefix of…
A: Since the programming language is not mentioned in the question, we will answer this question in the…
- Option A - A variable num modulo 2 is used to check the num variable is even or not. The modulo operator is used to check the remainder value.
- Option B - Same num variable is checking with the value of modulo 0. The even number checks based on the value modulo 2, not 0 and it is not equivalent to 2. Numbers are interchanged in this condition.
- Option C - The modulo 1 is not checking for the even number; the condition should return 'true' as per the specification prompted.
- Option D - The equivalent number value is not 2 and then the modulo should be modulo 2, not modulo 1. It will return the 'false' and wrong checks.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a table already taken, reprompt the user. Continue to accept reservations until the user enters a sentinel value or all slots are filled. Then display all empty tables in each time slot. For this homework assignment you need to: create a flowchart using RAPTORLe Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m.Design a program that accepts reservations for specific tables at specific times; the user entersthe number of customers, the table number, and the time. Do not allow more than four guests pertable or invalid table numbers or times. If an attempt is made to reserve a table already taken,reprompt the user. Continue to accept reservations until the user enters a sentinel value or allslots are filled. Then display all empty tables in each time slot. Pseudocode and flowchart (RAPTOR please) if possible. Do not write it in any particular language, that is not required.Complete the Funnyville High School registration program where user is prompted for her full name and the program generates email id and temporary password. Sample run: generate_EmailID: This function takes two arguments: the user’s first name and last name and creates and returns the email id as a string by using these rules: The email id is all lower case. email id is of the form “last.first@fhs.edu”. e.g. For "John Doe" it will be "doe.john@fhs.edu". See sample runs above. generate_Password: This function takes two arguments: the user’s first name and last name and generates and returns a temporary password as a string by using these rules. Assume that user's first and last names have at least 2 letters. The temporary password starts with the first 2 letters of the first name, made lower case. followed by a number which is the sum of the lengths of the first and last name (For example this number will be 7 for "John Doe" since length of "John" is 4 and length of "Doe" is…
- A(n) __________ is a special variable that receives a piece of data when a function is called.a. argumentb. parameterc. headerd. packetATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. Your task is to create a function that takes a string and returns true if the PIN is valid and false if it's not. Examples validatePIN("1234") ➞ true validatePIN("12345") ➞ false validatePIN("a234") ➞ false validatePIN("") ➞ false Notes ● Some test cases contain special characters. ● Empty strings must return false.# Question 4def costume_rating(costume_color, bling_value): """ Returns a function that calculates the number of candies to return based on the costume color, bling value, and phrase length. Args: costume_color (str): The color of your costume. Must be one of 'blue', 'red', 'green', 'yellow', 'purple', or 'orange'. bling_value (int): Represents how shiny your costume is. Must be a positive integer. Returns: A function that takes in one parameter: phrase (str): The phrase said by the trick-or-treater. >>> costume_rater = costume_rating('blue', 5) >>> costume_rater('19 Character Phrase') 85 >>> costume_rater('e') 0 >>> costume_rater('seven c') 1 >>> costume_rater = costume_rating('orange', 8) >>> costume_rater('hello i want candy') 14 >>> costume_rater = costume_rating('yellow', 5) >>> costume_rater('please give me…
- num1 – a positive integer representing the first digit in the combination num2 – a positive integer representing the second digit in the combination num3 – a positive integer representing the third digit in the combination num4 – a positive integer representing the fourth digit in the combination num5 – a positive integer representing the fifth digit in the combination Description: You own a combination lock that only opens when presented with the correct sequence of odd and even numbers that are less than 10. Write a function that takes in 5 integers. Check whether they are in this order: odd, even, odd, even, odd. If they are in the correct order and all below 10, then print the string “You opened the lock.” Otherwise, print “You are locked out.” Enclose function in a while loop and ask user for parameters using input(). Test Cases: >>>comboLock(9, 2, 5, 4, 1) You opened the lock. >>>comboLock(1, 8, 3, 6, 8) “You are locked out.” >>>comboLock(2, 2, 5, 6, 4)…most_frequent_word() takes a string as the input parameter and returns two values; the word that appears most frequently in that string and the total number of times that word appears in that string. In case of a tie, return the first word that appears in the string. Hint: you can use the unique_words function that you wrote in (4). Sample outputs:>>> data = “chapter one hottest day summer so far drawing close drowsy silence lay over large square houses privet drive cars usually gleaming stood dusty drives lawns once emerald green lay parched yellowing”>>> word = most_frequent_word(data)>>> print(word)('lay', 2)>>> data_2 = "a cat in a hat and a big black bear on a big black rug">>> word = most_frequent_word(data_2)>>> print(word)('a', 4)C++ Language Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:"Hello! I'm Miley! Nice to meet you!" #include <iostream>#include <cstring>using namespace std; void MakeSentenceExcited(char* sentenceText) { /* Your solution goes here */ } int main() { const int TEST_STR_SIZE = 50; char testStr[TEST_STR_SIZE]; cin.getline(testStr, TEST_STR_SIZE); MakeSentenceExcited(testStr); cout << testStr << endl; return 0;}
- PHP ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. *With user input ($pinNumbers), create a function that takes a string and returns true if the PIN is valid and false if it's not. Examples validatePIN("$1234") ➞ true validatePIN("12345") ➞ false validatePIN("a234") ➞ false validatePIN("") ➞ false Notes ● Some test cases contain special characters. ● Empty strings must return false.// Fix this program that works// Use welcome function that display the message in diffreent color// Use Draw function to diplay table in gree/yellow// Remove, add, any code that you believe is not useful#include <iostream>#include <windows.h> using namespace std;char mat[3][3];void table(); //function to print the tablevoid welcome(); //function for welcome screenint main(){ int i, j, m, n, sum = 0; char ch; welcome(); system("pause"); for (m = 0; m < 3; m++) for (n = 0; n < 3; n++) mat[m][n] ='W'; table(); while (sum < 10) { //================== for player 1 =================== cout << "Player 1 is X Choose the position : "; cout << "Row:"; cin >> i; cout << "Coloumn:"; cin >> j; //============== if position is wrong ============ for (; i > 3 || i < 1 || j>3 || j < 1 || ('x' == mat[i - 1][j - 1] || 'o'…#include <iostream> using namespace std; int main() { string c_name ; string car_n; int n, member_n , total ,d; char choice; cout<< "Muscat Auto Workshop"<<endl<<endl; cout<< "Enter customer name : ";cin>>c_name; cout<<" Enter car plate number : ";cin>>car_n; cout<<" choice the required service "<<endl; cout<<" 1-Basic Tuning : 50 OMR "<<endl; cout<<" 2-Software Re-installation : 60 OMR "<<endl; cout<<" 3-Parts Replacement : 100 OMR"<<endl; cout<<" 4-Body Paint : 120 OMR"<<endl; cin>>n; if(n==1) { cout<<" charges before discout = 50 OMR "<<endl; } else if ( n==2) { cout <<" charges before discount = 60 OMR "<<endl; }else if (n==3) { cout<<" charges before discount = 100 OMR "<<endl; }else if (n==4 ) { cout<<" charges before discount = 120 OMR"<<endl; } cout<<" Do you…