Given that two int variables, total and amount, have been declared, write a sequence of statements that: • initializes total to 0 • reads three values into amount, one at a time. After each value is read in to amount, it is added to the value in total (that is, total is incremented by the value in amount). T T T F Paragraph 3 (12pt) - T 日iN公 Arial T T, O f Mashups E E H O I HTML CSSS
Q: 7) ( )If we define variables: int a=2, b-4, c-6; the value of the following expression ((a> b? a: b)…
A: The required code has ternary operators (denoted by '?' which is short form of if-else) and thus are…
Q: What will the following programs print on the screen? A) #include <iostream>using namespace…
A: A) OUTPUT: 0…
Q: Q3 Let U = {5, 6 }, write an equivalent to the following assertions: 3x P ( x ) v - Vx Q ( x ) Q4.…
A:
Q: 3. What does this code print? int i = 0; while (i < 12) { int j; for (j = 0; j < i; j++) { if…
A: this code prints: i = 16.
Q: Given four values representing counts of quarters, dimes, nickels and pennies, output the total…
A: 1 dollar=4 quarters 1 dollar=10 dimes 1 dollar=20 nickels 1 dollar=100 pennies
Q: 1. Identify the tokens in each of the following statements. (You do not need to classify them; just…
A: Actually, Token Token is a set of character that treated as single entities. Lexical analyzer is a…
Q: In C++ 2.12 LAB: Hypotenuse Given two numbers that represent the lengths of a right triangle's…
A: Algorithm: The algorithm for the given problem is: Start Initialise two variables Read the values…
Q: 1.Given the following declarations, evaluate the expression below and assign true or false value for…
A: In step 2 I am giving the Source code in C language, as there is no particular language mentioned…
Q: Assume that int a = 5 and double d= 5.0, what is the result of a in the following expression? =16 34…
A: - The question is to know the value of expression provided :: a = 16 + 34 % 4 * ( 60 * 6 % 2) Here a…
Q: Given the following: int s = 50; int t = 25; s= ++t - 5; s+t; t = s + 3; a. What is the value of s…
A: a) The value of s will be 22 SCREENSHOT OF OUTPUT:-
Q: Suppose that x, y, z, and w are int variables. What is stored in x, y, z, and w after the following…
A: x = 25; // x = 25 y = x - 6; // y = 25 - 6 = 19 z = (y + 11) % 9; // z = (19 + 11) % 9 = 30…
Q: Suppose that x, y, z, and w are int variables. What is stored in x, y, z, and w after the following…
A: PROGRAM: //Header file #include <iostream> using namespace std; //main() int main() {…
Q: Given four values representing counts of quarters, dimes, nickels and pennies, output the total…
A: 1) Below is C++ program that input quarters, dimes, nickels and pennies and output total amount of…
Q: What is wrong with the following programs(one problem each)? nclude ing namespace std; t main() {…
A: Solution :
Q: The following statements shown below will result in the printing of: for (i= 3; i < 15; i += 3) {…
A: Question 3 is incomplete so I will do 1 and 2. For part 1, i is incremented by 3 and also after…
Q: ories ( (Age x 0.2757) + (Weight x 0.03295) + (Heart Rate x 1.0781) – 75.4991) x Time / 8.368 te a…
A: CODE : #include<bits/stdc++.h> using namespace std; int main(){ double age; // variable…
Q: (S), Il ally, I ) #include main() { int x[5], *y,z[5] for(i=0;i void main(){ int x,y; cin>>x; for…
A: Answer is given below. (i) Will encounter a following syntax error(s): The variable ‘i’ is not…
Q: 4) write down whether the following statements is valid or not valid int i=11, m-51%; int *pl, *p2,…
A: Only the second statement is valid.
Q: What would be the value of i and j after the ?following code executed ;int i = 5 ;++int j = i ;cout…
A: d) 75 Step by Step Execution : i = 5 j = i++ = 5 ( Value is first used and then incremented , j is…
Q: Q2:a) What is the output of the following program? Void main() {for(int i=4;i>=1;i--) { for(int…
A: This is the case of nested for loop. Here outer loop is managing number of rows and inner loop is…
Q: Consider the following lines of code: int test1 = 83; int test2 = 90; double average = (test2 +…
A: The answer for this "No"
Q: 8. Determine the value of variable num1, num2 and num3 at the end of the following code. int…
A: #include<stdio.h>int product(int A, int *B) /* function definition. As at the time of calling…
Q: 5. Given variables int areaBound and int sum, write a snippet of code that assigns to sum the result…
A: Given:
Q: ger, print out, the string "bad value(s) in:" followed by the names of the variables that have bad…
A: As not specified I have solved the question using Python language Code: x = input("Enter value for…
Q: QI: Answer all of the following: 1- If the following lines of code have errors, correct them;…
A: To Do: To write the answers.
Q: 3. Count Even N(from codeChum, modified) 1 #include #include"positive.h" int main(void) { int n =…
A: I give the code in C as per your requirement and also provide the output and code screenshot
Q: Consider the following statements: i- 42; int p; After these statements, which of the following…
A: Here k is storing address of i with the statement k=&i With the statement p=k, p is storing…
Q: e) In the statement cin >> y; y can only be an int or a double variable. O True False
A: False.
Q: Suppose that i and j are both of type int. What is the value of j after the following statement is…
A: Introduction: The above code uses for loop and the for loop iterates 10 times and the initial value…
Q: 4. What is the range of the random number generated from this equation: 2+ (int) (Math.random()* 99)…
A: Question 4: The Math.random() function is used for returning a pseudo random number which is of…
Q: Suppose that x, y, z, and w are int variables and x = 25, y = 3, z = 12, and w = 4. What is the…
A: a. Program: //include the header file #include <iostream> using namespace std; //definition…
Q: Write a statement or a set of statements to accomplish each of the following tasks:a) Sum the odd…
A: As per our guidelines, we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: 16. Consider the following code: ot her = True 1 - int (input (OMumber: )) if other and x > 0: print…
A: Answer: Code: other = Truex = int(input("Number: "))#taking user input#condition checking to print…
Q: 5. Given variables int areaBound and int sum, write a snippet of code that assigns to sum the result…
A: Here in this question we have asked to write a snippet of code that use while loop and Initially…
Q: Consider the following statements: alist = ['a', 'b', 'c', 'd', 'e', 'f'] del alist[1:5] After the…
A: In this question Here we have given some python code.and we have to execute that code on that code…
Q: Suppose n1 and n2 are two int variables that have been given values. Write anif-else statement that…
A: here in this question we have two variable and we have asked to write if else statement it outputs…
Q: Q1:Find the output of the following code: const int x=3; const int y=2; double a[x]…
A: #include <iostream>using namespace std; int main(){ const int x=3; const int y=2;…
Q: Suppose x, y, and z are int variables and x=2, y=5, and z=6. What is the output of each of the…
A: The problem is based on arithmetic calculations and basic input operations in C++.
Q: What would be the value of i and j after the following code executed? int i = 5; int j = i++; cout…
A: Here the initial value of i is set to 5. Now we have done post-increment to the value of i, which…
Q: Q8) Write the output for each of the following statements? Each group is independent of the others…
A: Note: Since you have posted multiple independent questions in the same request, we will solve the…
Q: What is the output of the following program? #include using namespace std; int main () { int i,…
A: for(i = 9; i > 5; i = i - 2) cout << " " <<i+1; The above loop executes like…
Q: can you make a flow chart of this: #include int main(){ int num1, num2;…
A: #include <stdio.h> int main(){ int num1, num2; for(num1 = 1; num1 <= 10;…
Q: 3. After execution of the following code, what is stored in valueNum? All variables are using data…
A: The correct option is option b which is the largest value of num1,num2, and num3. The value stored…
Q: Q2: What is the output of the following statements: ماهي نتائح كتفير الخطوات التالية int a,b,k,…
A: //Tracing code for output int a,b,k,x=1,y=2; cout<<"a b"<<endl;//prints a…
Q: in the space provided below: Consider the following variable declaration int m = 8, n, r = 4, p;…
A: int m=8, n, r=4, p; double q; n=r*(r/m)<m; p=r<m/2&& r/r>=m || (q=(r*=2)/m)>1;…
Q: Suppose we add $100 to a checking account in year 1, $200 in year 2, $300 in year 3, and so on. The…
A: #include <iostream>using namespace std; int main(){ double balance = 0; int year = 0;…
Q: Q2:a) What is the output of the following program? Void main() {for(int i=4;i>=1;i--) { for(int…
A: Please find the answer below :
Q: What is the last value of F after executing the following code? int T=2, F=10; do { while (F =T); O…
A: The "while" loop is a pre-condition check loop that tests the condition of the loop before the…
Q: 3. (5 points) Suppose P(x,y) means "x * y = y * x", where x and y are real numbers. Determine the…
A: A truth value for a statement is used to show truth or falsity of a statement. The truth value of a…
Q: nvert the following statements into intermediate code: int r=0; for (int i=0; i<10; i++)…
A: Convert the following statements into intermediate code: int r=0;for (int i=0; i<10; i++)…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- (Modify) Rewrite the following programs to conform to good programming practice and correct syntax: a. #include using namespace std; int main( ){ cout << “The time has come” ; return 0;} b. #include using namespace std; int main ( ){cout << “Newark is a city\n”;cout << “in New Jersey\n”; cout << “It is also a city\n” ; cout << “in Delaware\n” ; return 0;} c. #include using namespace std; int main() {cout << Reading a program\n”;cout << “is much easier\n” ; cout << “if a standard form for main is used\n” ; cout <<“and each statement is written\n”;cout << “on a line by itself\n” ; return 0;} d. #include using namespace std; int main ( ){ cout << “Every C++ program” ; cout <<“\nmust have one and only one” ; cout << “main function” ; cout << “\n The escape sequence of characters”) ; cout << “\nfor a newline can be placed anywhere” ; cout <<“\n in the message passed to cout” ; return 0;}Given the declaration:char myStr[26];char yourStr[26] = "Arrays and Strings";a. Write a C++ statement that stores "Summer Vacation" in myStr.b. Write a C++ statement that outputs the length of yourStr.c. Write a C++ statement that copies the value of yourStr into myStr.d. Write a C++ statement that compares myStr with yourStr and stores the result into an int variable compare.int fun(int k){ return ( ); void main(){ int n; cin >> n; n = n * fun(n); <-- 1 Fill in the appropriate statement and expression in fun, so that when it is called in main, and after the execution of the statement marked 1, the value of n would always be n3.
- Modify the following code with the comment include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <time.h> int main(void) { int arr[2][2] ={{500, 1000}, {750, 325}}; char name, acc_type; int amt; printf("\nEnter your name:") scanf("%c", &name) ; getchar(); printf("\nWould you like you withdraw from (c) Checkings or (s) Savings:") ; scanf("%c", &acc_type) ; printf("\nHow much would you like to withdraw:"); scanf("%d", &amt); if(name == 'a') { switch(acc_type) { case c: printf("\n Amount in account to be withdrawn from: 500"); printf("\nAmount in account after withdrawal:%d",500-amt);break; case s: printf("\n Amount in account to be withdrawn from: 1000);printf("\nAmount in account after withdrawal:%d",1000-amt);break; } } if(name=='b') { switch(acc_type) { case c: printf("\n Amount in account to be withdrawn from: 750"); printf("\nAmount in account after withdrawal:%d",750-amt);break; case s: printf("\n Amount…need help with python...please paste indented code here QUESTION 1 Implement the following:Given:item1 = "Pens"item2 = "Pencils"price1 = 0.99price2 = 1.5 Print two f-string statements to display the following according to the rules below:1) Item prefixed with 'New markdown:'2) Price prefixed with 'Buy one get one free: $'3) Item always has 12 characters of space.4) Price is always displayed with two decimal places. Example OutputNew Markdown: Pens Buy one get one free: $0.99New Markdown: Pencils Buy one get one free: $1.50I get an error when I submit my program. My code is as follows #include<iostream> using namespace std; int main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); // show decimals even if not needed cout.precision(2); // two places to the right of the decimal // TODO: enter the missing types below int time; float ticketPrice; char destination; //'C'=Chicago, 'P'=Portland, 'M'=Miami char typeOfDay; //'D'=weekDay 'E'=weekEnd bool isDayTime = false,isWeekend; cout << "Welcome to Fordham Airlines!" << endl; cout << "What is your destination? ([C]hicago, [M]iami, [P]ortland) "; cin >> destination; cout << "What time will you travel? (Enter time between 0-2359) "; cin >> time; // TODO: set isDayTime to true if time 5AM or later, but before 7PM if(time>500&&time<1900){ isDayTime = true; } cout << "What type of day are you traveling? (week[E]nd or week[D]ay) "; cin >> typeOfDay; // TODO: set isWeekend to true if typeOfDay…
- int main() { int i, salary[10], range[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; double gross[10], total[10]; string amount[9]={"$200 - $299", "$300 - $399", "$400 - $499", "$500 - $599", "$600 - $699", "$700 - $799", "$800 - $899", "$900 - $999", "$1000 and over"}; for (i=0; i<10; i++){ cout<<"Please enter gross sales of salespeople "<<i+1<<": "; cin>>gross[i]; total[i]=200+(gross[i]*0.09); salary[i]=total[i]; if (salary[i]>=200 && salary[i]<=299) range[0]=range[0]+1; else if (salary[i]>=300 && salary[i]<=399) range[1]=range[1]+1; else if (salary[i]>=400 && salary[i]<=499) range[2]=range[2]+1; else if (salary[i]>=500 && salary[i]<=599) range[3]=range[3]+1; else if (salary[i]>=600 && salary[i]<=699) range[4]=range[4]+1; else if (salary[i]>=700 && salary[i]<=799) range[5]=range[5]+1; else if (salary[i]>=800 && salary[i]<=899) range[6]=range[6]+1; else if (salary[i]>=900…Here is the code I have so far. The areas with " // " are where i need help. Thank you#include <iostream>#include <iomanip>using namespace std;double loan_amount = 50000.00;int number_of_years = 5 ;double yearly_percent_int ;double yearly_interest; double monthly_interest; int number_payments; double getpayment(double apr){double payment = 0.00 ; yearly_percent_int = apr; // I need help with coding the payment computer herereturn payment;}void print(double yearly_percent_int, double payment){// need help here as well}int main()int n = 1;double apr1, apr2, apr3;double pay1, pay2, pay3;cout << "Welcome to the Mortgage Payment Tool of Dr. Simon Lin!" << endl << endl;cout << n++ << "=====================================================." << endl << endl;cout << ">> Enter 3 Annual % Interest Rate (such as 1.5 2.75 4.50):" << endl;cin >> apr1 >> apr2 >> apr3 ;cout << endl << n++ <<…#include <iostream>#include <iomanip>#include <cmath>using namespace std; #define PROPERTY_TAX_RATE_PER_YEAR 1.25#define COST_OF_UTILITIES_PER_MONTH 300.00#define COST_OF_INSURANCE_PER_YEAR 550.00 void inputData(double& sellingPrice, double& interestRate, int& durationOfLoan); void handleAllComputations(double sellingPrice,double interestRate,int durationOfLoan,double downPaymentRate,double& downPayment,double& amountOfLoan,double& mortgagePayment,double& propertyTax,double& costOfInsurance,double& totalMonthlyHouseCost); double calculateDownPayment(double sellingPrice, double downPaymentRate);double calculateAmountOfLoan(double sellingPrice, double downPayment);double calculateMortgagePayment(double amountOfLoan,double interestRate,int durationOfLoan); void outputResults(double sellingPrice,double downPayment,double amountOfLoan,double interestRate,int durationOfLoan,double mortgagePayment,double propertyTax,double…
- Assume that a box of apples cost 8 dollars and a box of grapes cost 6 dollars. Given variables numBoxApples and numBoxGrapes that are read from input, compute the total cost and assign combinedCost with the result. Ex: If the input is 7 10, then the output is: Cost: 116 include <iostream> using namespace std; int main() { int applePrice = 8; int grapePrice = 6; int numBoxApples; int numBoxGrapes; int combinedCost; cin >> numBoxApples; cin >> numBoxGrapes; /* Your code goes here */ cout << "Cost: " << combinedCost << endl; return 0; }Assume variables a, b, c, are declared int and are initialized. Write code that will find the largest value of a, b, and c, and store the largest value to int variable smallest. (code in C)// P41.cpp - A simple elevator for 4 floors and a basement with a // close door button and 5 keys for floors #include<iostream> #include<cmath> using namespace std; void close_door(); int change_floor(int choice, int floor); int main( ) { int key; int floor = 0; cout << "Press a Key \n"; cin >> key; if(key == 0) { close_door(); if( floor != 0){ // otherwise nothing happens cout << "I am moving to the Basement \n"; floor = change_floor(0, floor); } } else if(key == 1) { close_door(); if( floor != 1){ // otherwise nothing happens cout << "I am moving to the the First Floor \n"; floor = change_floor(1, floor); } } else if(key == 2) { close_door(); if( floor != 2){ // otherwise nothing happens cout << "I am moving to the the Second Floor \n"; floor = change_floor(2, floor); } } else if(key == 3) { close_door(); if( floor != 3){ // otherwise nothing happens cout << "I am moving to the the Third Floor \n"; floor = change_floor(3, floor); } }…