Concept explainers
Explanation of Solution
Output of the Given
//Header files
#include<iostream>
using namespace std;
//main function
int main()
{
//Declare and initialize the variables
const int UPPER = 8, LOWER = 2;
int num1, num2, num3 = 12, num4 = 3;
/*Check whether the value of 'num3' is less than 'num4' if it is true then 'UPPER' value is stored in the variable 'num1' otherwise 'LOWER' value is stored in the variable 'num1'*/
num1 = num3 < num4 ? UPPER : LOWER;
/*Check whether the value of 'num4' is greater than 'UPPER' if it is true then 'num3' value is stored in the variable 'num2' otherwise 'LOWER' value is stored in the variable 'num2'*/
num2 = num4 > UPPER ? num3 : LOWER;
//Print the values
cout << num1 << " " << num2 << endl;
//return statement
return 0;
...Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
- You are developing a Fraction structure for Teacher’s Pet Software. The structure contains three public data fields for whole number, numerator, and denominator. Using the same structure, write the functions described below: • An enterFractionValue()function that declares a local Fraction object and prompts the user to enter values for the Fraction. Do not allow the user to enter a value of 0 for the denominator of any Fraction; continue to prompt the user for a denominator value until a valid one is entered. The function returns a data-filled Fraction object to the calling function. • A reduceFraction()function that accepts a Fraction object and reduces it to proper form, returning the reduced Fraction. For example, a Fraction entering the function as 0 2/6 would be reduced to 0 1/3, and a Fraction entered as 4 18/4 would be reduced to 8 1/2. • A displayFraction()function that displays any Fraction object passed to it. This function displays a fraction with a slash between the…arrow_forwardFunction 3: Positive Unique Numbers _missingSpace(string) Create a JavaScript Arrow function that meets the following requirements: • Authored using arrow expression syntax (constant name _missingSpace) • The function is passed a string argument • The function inserts a white space between every instance of a lowercase character followed immediately by an uppercase character, and returns the modified string, with whitespaces, back to the caller. • Console log output is NOT permitted.arrow_forwardwhat is each line of the code below do? #include "mbed.h"#include "Servo.h"#include "Map.hpp" 1. AnalogIn JoystickPin1(A0);2. AnalogIn JoystickPin2(A1); 3. Servo ServoMotor1(D3);4. //Servo ServoMotor2(D4); 5. Map AnalogPos(0,1023,0,180); 6. int main(){7.float Position1,Position2; 7. while (true) { 8. Position1=AnalogPos.Calculate(JoystickPin1.read());9. Position2=AnalogPos.Calculate(JoystickPin2.read()); 10.ServoMotor1.position(Position1); 11. printf("JoyStick1");12. printf("%f",Position1); 13. printf("JoyStick2"); 14. printf("%f",Position2); 15. ServoMotor1.position(Position1);}}arrow_forward
- Please Write a function to validate an email. Below is the html element we're validating, please make the java code as simple as posible thank you. The validation should check for: if the numbers were 1 through 9 if there is a name if email is valid if cell phone i valid if Card number, EXP date and CVV is valid or not if the address is valid or not <div class="bg"> <div class="in"> <div class="ro"> <img class="ba"src="stle/pg1/logo.png"> <div class="C">+</div> <form id="result" action="#"> <input type="text" placeholder="Choose from item 1-9"> <input type="text" placeholder="Name"> <input type="email" placeholder="E-mail@gmial.com" id="email"> <input id="Phone nuber" type="text" placeholder="Phone number"> <input id="Card Number" type="text" placeholder="Card Number"> <input id="Card Exp Date" type="text"…arrow_forward// Program 4.8.1 #include <iostream>#include <cstring>using namespace std;int main (){char str1[10] = "Hello";char str2[10] = "World";char str3[10];string str4 = "Hello";string str5 = "World";string str6;int len1, len2 ;cout << "==============================="<< endl;cout << "Copy string"<< endl;cout << "-------------------------------"<< endl;str6 = str4;cout << "str6 : " << str6 << endl;strcpy( str3, str1);cout << "strcpy( str3, str1) : " << str3 << endl<<endl;cout << "==============================="<< endl;cout << "Concatenates string"<<endl;cout << "-------------------------------"<< endl;str6 = str4 + str5;cout << "str4 + str5 : " << str6 << endl;strcat( str1, str2);cout << "strcat( str1, str2): " << str1 << endl<<endl;cout << "==============================="<< endl;cout << "String…arrow_forwardPlease provide proper comments. Define the following code. #include <stdio.h>2 #include <string.h>34 #define STRING_LEN 205 #define SONG_BANK 56 #define SONGS 378 struct Song9 {10 char title[STRING_LEN + 1];11 int seconds;12 };1314 void calculateTimeFormat(int tSeconds, int* minutes, int* seconds);15 void createPlaylist(struct Song playlist[], const struct Song bank[], int offset, int seed, int order[]);16 void playSongs(const struct Song songs[], const int order[], int crossFade);1718 int main(void)19 {20 //21 struct Song songBank[SONG_BANK] = { {"Song1", 546},22 {"Song2", 295},23 {"Song3", 399},24 {"Song4", 234},25 {"Song5", 111} },26 playlist[SONGS] = { {0} };2728 //29 //30 //31 int shuffled[SONGS] = { 0 }, config1 = 1, config2 = 26, config3 = 9;32 33 createPlaylist(playlist, songBank, config1, config2, shuffled);34 playSongs(playlist, shuffled, config3);3536 return 0;37 }3839 void calculateTimeFormat(const int tSeconds, int* minutes, int* seconds)40 {41 *minutes =…arrow_forward
- Assignment Name JavaScript Concepts III Assignment Filename lastname-circleArea.html (replace lastname with your last name). area.js Assignment Description This assignment demonstrates the following concepts: JavaScript Functions Assignment Instructions Write a JavaScript program that calculates the area of a circle: Write a function that calculates the area of a circle given the radius. Formula: Math.PI * (radius * radius) Your program code should contain appropriately named variables. Use documentation to identify various components of your program. Call the function once and pass a radius value of 10.75 to it. Use the starter files and complete the logic to satisfy the instructions. To access the files, download and save the circleArea.zip folder attached to this assignment. Then unzip the compressed folder to reveal the included files: circleArea.html and area.js. Be sure that the two files are in the same folder. Then write your code in the area.js…arrow_forwardComputer Science The program below uses a class, DomainAvailabilityTools, which includes a table of registered domain names. The main function prompts for domain names until the user presses Enter at the prompt. The domain name is checked against a list of the registered domains in the DomainAvailabilityTools class. If the domain name is not available, the program displays similar domain names. #include <iostream>#include <string>#include <cctype>#include "DomainAvailabilityTools.h"using namespace std; // *********************************************************************** // prompts user string. Returns string.string GetString(string prompt) {string userInput; cout << prompt << endl;cin >> userInput; return userInput;}// *********************************************************************** int main() {const string PROMPT_DOMAIN_NAME ="\nEnter a domain name to check availability (Enter to exit): ";DomainAvailabilityTools dvTools; string…arrow_forward#include <ctime>#include <cstdlib>#include<iostream> using namespace std; char choice;void printMenu();int getSelect(int&);bool isUnique(int[], int, int);void printArray(int[], int); int drawing[] = { 56,34,1,8,12 }; int main(){ int sel; printMenu(); getSelect(sel); return 0;} void printMenu(){ cout << " Welcome to the Lottery\t\n"; cout << "---------------------------------\n"; cout << " 1. Quick Pick\n"; cout << " 2. Pick Numbers\n"; cout << " 3. Exit\n";} void selection1_output(){ int r[5]; for (int i = 0; i < 5; i++) { r[i] = 1 + (rand() % 69); } cout << "Players Ticket : "; for (int i = 0; i < 5; i++) { cout << r[i] << " "; } cout << "\nDrawings : "; for (int i = 0; i < 5; i++) { cout << drawing[i] << " "; } int same = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j…arrow_forward
- For this C# program writen in Visual Studio code, I need added on the end the Last Value Divided by the First Value. Here is the code... class Program { static void Main(string[] args) { UniqueValueApp myApp = new UniqueValueApp(); myApp.GetValues(); myApp.DisplayValues(); myApp.minValue(); myApp.maxValue(); myApp.sumOfValues(); myApp.avgOfValues(); } } class UniqueValueApp { private List<int> _list = new List<int>(); public void GetValues() { int value; bool result; Console.Write("Please enter an integer: "); string input = Console.ReadLine(); while (input != null) { result = int.TryParse(input, out value); if (result) { if (value > -1 && value < 100)…arrow_forwardThe show_sequence function at below is part of chapter 3 program. What kind of passing does this function us and why? void show_sequence(sequence display) // Library facilities used: iostream{ for (display.start( ); display.is_item( ); display.advance( )) cout << display.current( ) << endl;} Group of answer choices It uses a value parameter. The reason is the advancing of the current element through the sequence would alter the actual argument. That is what we want. It uses a value parameter. The reason is the we don't want the advancing of the current element through the sequence to alter the actual argument. It uses a geneeral parameter. The reason is the we don't want the advancing of the current element through the sequence to alter the actual argument. It uses a reference parameter. The reason is the we don't want the advancing of the current element through the sequence to alter the actual argument. It uses a reference parameter. The reason is…arrow_forwardExercise #3 o Write a program averageLuminance(picture) which takes as input a picture uses functional programming to calculate the average luminance of the picture’s pixels. Use the helper function def luminance(pixel): r = getRed(pixel) g = getGreen(pixel) b = getBlue(pixxel) y = 0.2126 * r + 0.7152 * g + 0.0722 * b return y Within your main program, use map and luminance to create a list of luminances from the list of pixels. This is an example answer to help you formulate an answer for the question above: # Exercise 3 def isDocument(fileName): listOfEndings = [ ".docx", ".txt", ".rtf" ] for ending in listOfEndings: if fileName.endswith(ending): return True return False def recursiveListDocuments(directory=os.getcwd()): files = os.listdir(os.path.normpath(directory)) for file in files: fileName = os.path.normpath(directory + "/" + file) if isDirectory(fileName): recursiveListDocuments(fileName) else: if isDocument(fileName): print fileNamearrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning