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
Starting Out with C++: Early Objects
- in c language typedef _people { int age; char name[ 32 ] ; } People_T ; People_T data [ 3 ]; Using string lib function, Assign 30 and Cathy to the first cell, Assign 40 and John to the second cell and Assign 50 and Tom to the third cellarrow_forwardFunction for button "Publishing Date": • Name this function by your last name (for example, function yamoutl)). When the user clicks on the button "Publishing Date" (after filling all the textboxes), the current date and time will be printed after the text "Published on:" CSCI375 Grades Exam-1 (70 Exam-2 98 Project 86 Exam-3 80 Show the Grades Your Grades: Exam-1 - 78, Exam-2 - 98, Project - 85, Exam-3 - 80 Publishing Date Published on: 5/10/2021, 5:39:08 PM Change Background Colorarrow_forwardC++ Language Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton (Links to an external site.) temperatures. The formula for the conversion from Celsius to Fahrenheit is : F=9/5*C+32 F is the Fahrenheit temperature, and C is the Celsius temperature. The formula for the conversion from Celsius to Newton is C = 100/33*N N is the Newton Temperature and C is the Celsius temperature Your program should prompt the user for a lower value and upper value for a range of temperatures in Celsius. It should then prompt the user for the amount they want to increment by. Then use a loop to output to a file named conversion_table.txt a table of the Celsius temperatures and their Fahrenheit and Newton equivalents within the range of values using the increment given by the user. Make sure to format your output to 2 decimal places. INPUT VALIDATION: Ensure the second number is greater than the first number, and make sure the increment is greater…arrow_forward
- MP: Create a program using structures to compute for the final grade of a student with the following conditions; Prelim grade 30% Midterm grade 30% Finals grade 40% See screenshot below for your reference: Name: Juan Dela Cruz Prelim Grade: 89 Midterm Grade: 82 Finals Grade: 77 Student Name Final Grade : Juan Dela Cruz 82.10 Name: Bill Gates Prelim Grade: 77 Midterm Grade: 84 Finals Grade: 90 Student Name Final Grade : Bill Gates 84.30arrow_forwardquestion number 2arrow_forwardmy_func is a function as follows. What is the value of a at the end of the code beneath? function a = my_func (a) a = a + 1; end a = 0; for i = 1:3 my func (a); end a = my_func (a);arrow_forward
- C# program in Visual Studio Code. I need to be able to enter five integer values and then have the Unique values entered display. Private member variable to store 5 unique values (hint: use an Array or a List) Public function to get 5 unique values from the user and store them in the member variable loop to get the numbers, if a number is already stored, ignore it and keep looping until you have 5 unique numbers if a number is out of range, don't store the value, throw an exception and handle it in such a way that you don't break the loop but do message the user that the value was out of rangearrow_forwardBasic Variable Assignment A student learning JavaScript was trying to make a function. His code should concatenate a passed string name with string "Edabit" and store it in a variable called result. He needs your help to fix this code. Examples nameString("Mubashir") "MubashirEdabit" nameString("Matt") → "MattEdabit" nameString("javaScript")"javaScriptEdabit"arrow_forwardIn Python, grades_dict = {'Wally': [87,96,70], 'Eva': [100,87,90], 'Sam': [94,77,90], 'Katie': [100,81,82], 'Bob': [83,65,85]} Write your own describe function that produces the same 8 statistical results, for each one of the columns, that the built-in describe() function does. Note 1: Use the sample standard deviation formula (that is, the denominator is: N-1) Note 2: Your algorithm should work for any number of columns not just for 5 Note 3: You can use the np.percentile() for the 25% and 75% percentile as well as the sort() built-in functionsarrow_forward
- D11.arrow_forwardIn C programming language Question (Strings) Write a function find_Substring() that finds a substring into a string. Pass array s1 and s2 to this function and prints if the substring is present or not. Expected Output 1: Enter string This is a javascript Enter substring script The substring is present Expected Output 2: Enter string This is a javascript Enter substring Jscript The substring is not presentarrow_forwardInstructions Write a function create_password() expects two parameters: pet_name (a string) and fav_number (an integer). The function returns a new password generated using the following pattern: fav_number followed by the pet_name followed by the star * and fav_number again (see the example below). Create a program that gets a pet name and a favorite number as input from the user, calls the above function, and then prints the output as shown below. Example Input: Angel 3 Output: Your new password is "3Angel*3". Note that the double quotes are part of the output. The assert in the provided template is checking that this function call is returning the correct value (i.e., a correctly-formed string). assert create_password("Angel", 3) == "3Angel*3" Hints Remember that you cannot directly concatenate an integer and a string - you need to convert an integer into a string using either str() or by using f-strings. Troubleshooting If you are getting AssertionError make sure that your…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education