(a) Write two different techniques to declare and initialize a variable with an example. (b) Write a program that simulates a simple cakulator. It reads two integers and a character. If the character is a +", the sum is printod; if it is a -', the difference is printed; if it is a *, the product is printed; if it is a ", the quotient is printed; and if it is a "%", the remainder is printed.
Q: Answer properly(editable code , output screenshot) is must Write a C++ program to input…
A: Algorithm: 1.Declare main function 2.Declare variables named no_of_units to take units from the user…
Q: What is the output of the code below? def mystery_func(input, num, t = 0, x = 10, y = 10) [this…
A: The output of the code is 1.
Q: 6. Write a program segment using switch selection for the following statements. If the grade is A,…
A: As there is no programming language mentioned so program is attempted in c language Start input…
Q: Write a program that takes a range from the user and display all the even numbers between the range…
A: Note - Since there is nothing mentioned about the programming language to be used, so this program…
Q: 5) Write a program that reads three numbers and prints "increasing" if they are in increasing order,…
A: logic:- input three numbers . use > and && operator to check if they are in ascending…
Q: 4)Write program that input the user age and print the sentence: a) You are child if the age is less…
A: There is not mentioned any programming language so I used JAVA Step 1 : Declare a variable age and…
Q: 17. Write a program that calculates and print the numbers (from 0 to 10) and it squares and cubes.
A: Mathematically we know that square of a number is its multiplication by itself. For example if n is…
Q: Write a program that displays every integer between 1 and 100 that is divisible by 5 or 7, but not…
A: Algorithm: 1.Include required header files 2.include main function 3.create a for loop 4.use if…
Q: Let the following variable is declared in the C++ program as (int X;). Write one statement that…
A: Include the necessary header files. Declare the integer variable X. Get the input from the user. The…
Q: Can I please have the answer in C++ language 4.7: Time Machine Your time machine is capable of…
A: Lets see the solution.
Q: Q2/ Write a program that reads a code and temperature. If the code is 1, convert from centigrade to…
A: C programming: C programming is a procedural programming language that was developed by Dennis…
Q: (De Morgan’s Laws) In this chapter, we discussed the logical operators &&, ||, and !.…
A: According to De Morgan's Law, !(condition1 && condition2) = (!condition1 || !condition2)…
Q: Write a program to print the static F as shown below
A: Since programming language not mentioned using C++.
Q: Write a python program that displays every integer between 1 and 100 that is divisible by 5 or 7,…
A: Using While loop output : Editable code : i = 1while i<100 : if i % 5 == 0: if i…
Q: Write a single C statement to accomplish each of the following: c) Test whether the value of the…
A: Answer of the given question is as below: Approach: 1. Declare the variable count 2. Ask user for…
Q: Write program c++ to input a variable can accept any of the following value: A, & , B, 1, *, 3 as…
A: Sample Response: //C++ program to accept a value and prints its data type and…
Q: Q3: Write a program of c++ that prints the day number of the year, given the date in the form…
A: PROGRAM: // defining header file #include<iostream> using namespace std; // declaring…
Q: Given a and b are int variables and c is a double variable. The initial value for a, b, and c are 8,…
A: b++ is a post increment operation where the result in b updates after expression evaluation and thus…
Q: What is the value assigned to x after the following C expression is executed? int a=1, b=5, x; x=…
A: Please find the answer below
Q: (b) Given a and b are int variables and c is a double variable. The initial value for a, b, and c…
A: Postfix Operator: value of the variable is first used the expression and its incremented by 1. Since…
Q: (Racket) Write sequences of cars and cdrs that will pick the symbol 'x out of the following…
A: Given: (Racket) Write sequences of cars and cdrs that will pick the symbol 'x out of the following…
Q: Write a program to compare two fractional numbers by overloading relational operators (,=,==, !=)
A: //Please follow the coding in pictures #inсlude<iоstreаm>#inсlude<сstdlib>using…
Q: Program is to be written in C (1) Prompt the user for a string that contains two strings…
A: Based on our rules, we should answer only the first question when multiple questions are posted.…
Q: 9- Write a program which read a number of 3 digits and check if (units, tens, hundreds) digit is…
A: #include <stdio.h>int main(){ int digit[3],i=0,a=5; // Input the digit as an array…
Q: Let the following variable is declared in the C++ program as (int X;). Write one statement that…
A: cout is the keyword used to print if is the keyword used to check the condition
Q: Qno. 1 () Construct a program where implicit conversion would have been done. ii) Construct a…
A: i) #include <iostream> using namespace std; int main() { //declaring int variable int…
Q: Q1/A-Write a program to compute the mass flow rate of a fluid (in kg/sec) through a thermal unit…
A: Code: Dim A as DoubleDim M as DoubleDim Po as Double Dim K as DoubleDim R as DoubleDim T0 as…
Q: Exercise 5 : Write a C++ program that asks the user to enter the value for input variables, and…
A: I have provided both the programs in C++ language in step 2 with its outputs.
Q: use c++ Write a program that prompts the user to input a string (a string can be a word, a phrase…
A: In step 2, you will get the c++ code. In step 3, you can see the sample output.
Q: 3) Given three decimal numbers x, y and z. Write a boolean expression that evaluates to true if an…
A: I have provided the boolean expression in step 2.
Q: Q3] ( Write a program to enter a value of x and compute the value of y where x if x ≥ 0 -x if x<0 y
A: In mathematics function is the expression or rule or law which defines the relationship between the…
Q: Q7 Draw the flowchart and write a C program using else if to calculate the total amount to be paid…
A: The program prompts the user to enter basic loan amount and number of years. Basic loan amount is…
Q: Exercise 5: Write a C++ program that asks the user to enter the value for input variables, and…
A: The c++ code along with the output for division operation has given is step 2.
Q: Write a C++ program: Blood sugar is considered normal if its rate is less than 140 and greater than…
A: PROGRAM STRUCTURE: Include the required header files. Start the definition of the main function.…
Q: 2-Write a program which will read in three integers and will output the sum and average of the…
A: Program Plan: Input 3 integers from the user. Calculate the sum and average of the numbers.…
Q: 6. Write a program to read a number representing the time in 24-hours (i.e., 4-digits ). Then find…
A: import java.text.SimpleDateFormat;import java.util.*;import org.apache.commons.lang3.time; class…
Q: . In the sport of diving, seven judges award a score between 0 and 10, where each score may be a…
A: The program defines two variables: difficulty: for deciding the difficulty of each dive.…
Q: Q/ A College of engineering is advertised to call high school graduates to apply to its departments…
A: Problem Statement: A College of engineering is advertised to call high school graduates to apply to…
Q: Complete the program to read the needed values from input, that the existing output statement(s) can…
A: here is Programming Language is not mentioned so I will provide answers in c++ language. Code:…
Q: Write assignment statements that perform the following operations with int variable i, double…
A: GIVEN: int i; double d1, d2; char c; A) Subtract 8.5 from d2 and store…
Q: (c) You are required to create a program that reads a letter of the alphabet from the user. If the…
A: We want to check if the letter input is vowel or not, for y we have added a check, and printed…
Q: in C Write a program to calculate the size of a room and the costs to strip and sand, and seal it.…
A: 1) Below is C Program to calculate the size of a room and the costs to strip and sand, and seal it…
Q: Suppose x, y, and z are int variables and x = 18, y = 5, and z = 4. What is the output of each of…
A: Given, cout << "x = " << x << ", y = " << y << ", z = " << z…
Q: 2.Write a program that prompts the user to enter a positive integer and obtains its square root in…
A: The program is written in Java. Please find the source code in the next step.
Q: 2. Construct a program where you deciare and initialize a constant variable, now try to reassign…
A: EXPLANATION: The constant variables are basically those variables which can not be modified at the…
Q: 5) Write a program that reads three numbers and prints "increasing" if they are in increasing order,…
A: """Program reads three number and prints increasing, decreasing or neitherbased in its values…
Q: Write a Program to that will take input from the user and tells if the user entered Even or Odd…
A: Hey, since there are multiple questions posted, we will answer first question. If you want any…
Step by step
Solved in 2 steps with 2 images
- f. A laborant in a laboratory does a number of antigen tests in one day. Write a program that simulates the number of antigen tests done in a day in a laboratory, displays the number of positives and negatives, and calculates the % of positives in one day. Your program needs to first generate a random number that will show the number of tests done in a day. One laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one). Then for each of the tests, your program needs to generate a random number to show whether they are positive or negative. In order to write this program, you need to have the following three functions used by the main function: test result (void): This function generates a test result. It should randomly return either one or zero. 1 means positive test result and 0 means negative test result. float positive percentage (int,int) : This function takes the total number of positives and the total number of tests and returns the % of positives.…Take an Infix expression from the user and convert into postfix. 1. Should be self-organizing program e.g. If the user enters two operators back to back by mistake. The program should automatically delete one of the 2 operators. 2. If the user doesn't enter a multiplication sign before a bracket, the program should automatically insert a multiplication sign there.Three numbersa. Write a program that reads three numbers and prints “all the same” if they are allthe same, “all different” if they are all different, and “neither” otherwise.b. Write a program that reads three numbers and prints “increasing” if they are inincreasing order, “decreasing” if they are in decreasing order, and “neither”otherwise. Here, “increasing” means “strictly increasing”, with each value largerthan its predecessor. The sequence 3 4 4 would not be considered increasing.c. Repeat part b. but before reading the numbers, ask the user whetherincreasing/decreasing should be “strict” or “lenient”. In lenient mode, thesequence 3 4 4 is increasing and the sequence 4 4 4 is both increasing anddecreasing
- (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.6. A palindrome is a number or text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads a 5 digit integer and determines whether it is a palindrome. Hint: One way to do this is to use division (/) and modulus (%) operators to separate the number into individual digits.In CORAL LANGUAGE please and thank you! Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray.
- Write a program that reads student scores, gets the best score, andthen assigns grades based on the following scheme:Grade is A if score is ≥ best -5Grade is B if score is ≥best -10;Grade is C if score is ≥best -15;Grade is D if score is ≥best -20;Grade is F otherwise.The program prompts the user to enter the total number of students, and thenprompts the user to enter all of the scores, and concludes by displaying the grades.Here is a sample run: Enter the number of students: 4 ↵EnterEnter 4 scores: 40 55 70 58 ↵EnterStudent 0 score is 40 and grade is FStudent 1 score is 55 and grade is CStudent 2 score is 70 and grade is AStudent 3 score is 58 and grade is CWrite a c++ program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B C D The program should display the seat pattern, with an 'X' marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like this: 1 X B C D 2 A X C D 3 A B C D 4 A B X D 5 A B C D 6 A B C D 7 A B C D After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that that seat is occupied and ask…C++ One way to create a pseudo-random three digit number (and we are including one- and two-digit numbers as well) is rand()%1000. That gives numbers from 000 to 999, which is just what we want. Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is too high then the program should display "Too high, try again." If the user's guess is lower than the random number the program should say "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. The program should keep track of the number of guesses the user makes. When the user correctly guesses the random number, the program should display the number of guesses. As specified, have the program tell the player how many guesses were used. A good player should always be able to find a three-digit number in ten or fewer guesses. The programs needs to include a menu that allows the user to select easy (3 digit number),…
- discrete math programing python or c++ the range of values is from 0 to 5 Let Q(x, y) denote “x + y = 5” The domain of x and y is from range 0 to 5 . Implement the code that outputs the truth values of the following quantifications: 1. ∀x ∀y Q(x, y) 2. ∀x ∃y Q(x, y) **Display values of variables x and y if the quantification is true.Write a program that displays every integer between 1 and 100 that is divisible by 5 or 7, but not both. Write it using While and for.Write the following function to draw a regular polygon:def drawPolygon(x = 0, y = 0, radius = 50, numberOfSides = 3):The polygon is centered at (x, y) with a specified radius for the bounding circle for the polygon and the number of sides. Write a test program that displays a triangle, square, pentagon, hexagon, heptagon, and octagon, as shown in Figure 6.12a.