1. What is printed by the following code fragment? int x = 0; do { cout << x << ""; X++; }while (x < 10); cout << '\n'; 2. What is printed by the following code fragment? int x = 20; %3D do { cout << x << ""; x++; }while (x < 10); cout << '\n'; 3. Rewrite the following code fragment so a while loop is used instead of the for s for (int i = 100; i > 0; i--) cout <
Q: Suppose you were given the following code segment: int a[5] = { 1, 2, 4, 8, 16 }; int *p = a; int…
A: Concept of array and pointer is being used here, I have defined everything in comments of code , and…
Q: The steelwork.py program, given below, creates three types of steel objects. Carbon steel (Steel) is…
A: Actually, python is a easiest programming language. It has a concise(less) code. It is a dynamically…
Q: What will be output of the following c code? #include const enum Alpha { X, Y=5, Z }p=10; int…
A: The output of the following c code is -4 #include<stdio.h>const enum Alpha{X,Y=5,Z}p=10;int…
Q: Question 9 What are the values of x, y, and z after the following code executes? int x = 0; int y =…
A: Answer:
Q: What is the output of the following segment ? int y,x = 1,wW = while ( x <= 5 ) { y = x * x /s; WW…
A: 1) The above code segment calcaute the sum of series(x*x/2) from x =1 to x = 5 1*1/2 + 2*2/2 +…
Q: please provide the answers to the points in this variable trace Trace through the program below.…
A: From the given block of code Point #1, Variable x = 5 Point #1, Variable y = 6 Point #1,…
Q: What will be the value of ans after the following code has been executed? int x = 90, y = 55,…
A: ANS: - Option(3) 20 is correct. EXPLANATION: - Three integer variables x,y, and the ans are…
Q: Trace the following code and give the output int a = 6, b = 8; int c = (a < b) ? a : b; int v =…
A: Two integer variables a, b are declared with values 6 and 8. In the next step, there is a condition…
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: 10. What is the output of the following statement? int x=3; cout<<(++x* 2) <<"\"; cout<<(x--);
A: I will show output of this program.
Q: What is the output of the following segment of program? int[] value = {4,6,7,8}; int index; for…
A: Given Java Statements: int[] value = {4,6,7,8}; int index; for (index =…
Q: F1 is defined with the heading: void F1(int a, double &b, double t ); Assume the following…
A: GIVEN:
Q: What would be the results after the following code was executed? int[ ]x = {3,5, 3}; int[ ]y {6,8,…
A: Please give positive ratings for my efforts. Thanks. ANSWER Here, the loop is executed only once…
Q: 2. Write a program calculating the statistics for tests of a hospital by getting data from the user…
A: Algorithm Start Var t, pt, nt, ptr, ntr Accept total test in t Accept total positive test in pt…
Q: 30 Suppose a, b, and sum are int variables and c is a double variable. What value is assigned to…
A: Given: Suppose a, b, and sum are int variables and c is a double variable. What value is assigned to…
Q: 2. A) What could go wrong with the following code? double x = 4.12345 double z = 4.12; double y =…
A: Kindly Note: As per our guidelines we are supposed to answer only one question. Kindly repost other…
Q: 9- The script in the left side is used to solve the right-side equation. * #include #include using…
A: Given: A C++ program is given and an equation is given. Requirement: Choose whether the given code…
Q: What will be the output of this code? Int a = 5; int x = 3: a = 16; System.out.print(x); Question 4…
A: int a = 5; int x = a; a = 16; System.out.print(x); Output :- 5 Reason :- As x = a , this means we…
Q: Using R, write a program which will create a histogram with the following: X-axis labelof…
A: I've provided my own vector; please enter it into the variable vec of your data.
Q: Suppose x, y, and z are int variables and w and t are double variables. What value is assigned to…
A: Answer:
Q: Write the final output generated by the following program: b. #include #include void main() { int…
A: This question comes from Programming Language in C which is a paper of Computer Science. Let's…
Q: Create a function that finds the maximum range of a triangle's third edge, where the side lengths…
A: The python program for the above problem is given below in step 2.
Q: int sizeQfShaps (>= 2 and = 1 and =1 and < = 25) Test 2 For sizeofShape = 7, xCentre = 76, yCentre =…
A: java code for the above output
Q: What will be the output of the given program? #include using namespace std; void ref(int &a, int…
A: Find the output of the given C++ program.
Q: Let A = {4, {4, 5}, {5},Ø}. ANswer each of the following questions. 1) |A| = 5 2) Which of the…
A: Here in this question we have given a set A and based on this we have asked to answer true or false…
Q: Given the code below: type point real a, b end type type (point) v read*, v z=v%a/v%b print*,…
A: Wrong options none of the given code choices ,because option is there type point real a, b end type…
Q: " void Ahu (int &x, int &y, int z) X = 1; y = 2; 33; %3D %3D main () { int x = 113; int y = 22; int…
A: - We need to have the output for the snippet provided. - The code provided :-…
Q: What is the output of the following code segment? int num= 20, y = 5, x; cin>>X; if (x >= 2*num)…
A: Code: #include <iostream>using namespace std;int main(){ int num= 20, y = 5, x;…
Q: What is the ouput f the following code #include void fun (int *ptr) { --pt; } int main() {…
A: Given: What is the ouput f the following code #include <stdio.h> void fun (int *ptr) {--pt; }…
Q: Consider the following code snippet, and choose the best statement below: int cards[4]; for (int i…
A: If we store array element, from it size, then its was run successfully because there is no index out…
Q: 9- The script in the left side is used to solve the right-side equation. #include #include using…
A:
Q: In an alternate reality, chemistry Professors Hodge and Sibia have teamed up to design a chemical…
A: 1. loop until string length becomes 0 a. create new empty string temp b. loop for 0 to n…
Q: X = 2 + 3 * 4. What value will be assigned to the numeric variable x when the following statement is…
A: Here in this question we have given an expression x= 2+3*4 and we have asked what value will be…
Q: 3. A certain CS professor gives 100-point exams that are graded on the scale 90-100:A, 80–89:B,…
A: Ans: Code: score = int(input("Enter the exam score:"))if score > 90 and score < 100:…
Q: Write a program that does temperature converter", "- The user will enter if he wants the result in…
A: The following are steps needs to be taken for the given program: Asking user the temperature as…
Q: Accept a paragraph of text consisting of sentences that are terminated by either ‘.’ (full stop),…
A: EXPLANATION --> Firstly we will create a function to count no. of words in every sentence. Then a…
Q: What the output from executes this program? #include "iostream" using namespace std; int main() {…
A: Please find the answer below :
Q: Suppose x, y, and z are int variables and w and t are double variables. What value is assigned to t…
A: Answer is 81.50
Q: Question 6 What are the values of x, y, and z after the following code executes? int x = 0; = 1; int…
A: The answer is given below.
Q: 1. What is the output of the following code snipper? int num - 50; if (num > 50) : num - num -5:…
A: Question 1: The number is 50, so it will no enter the if clause and the output is 50. The answer is…
Q: Assuming x (type double) is 12.335 and i (type int) is 100, show the lines displayed by the…
A: Find Your Answer below
Q: 1. Examine the following code segment. What will be printed?If there are any errors indicate the…
A: The given C++ code segment is: int a[8] ={16, 12, 10, 7, 15, 18, 17, 29}; int *ptr ; ptr = & a[…
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: Given that x = 0, what is the output of this code #include int main (void) { int x; printf…
A: GIVEN: Given that x = 0, what is the output of this code #include <stdio.h> int main (void)…
Q: Write a Little Man program that prints out the multiples of 9 starting from 9 to 99. Also keep a…
A: Given: Multiples of 9 starting from 9 to 99 Total and output at the end the sum of 9+18+...99
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: Assume the following code segment is in a complete program: void SomeFunction( int&, int);…
A: Code: #include <iostream>using namespace std; void SomeFunction( int&, int); int…
Q: Scanner keyboard new Scanner (System.in); String s = keyboard.next (); System.out.println (s);…
A:
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 7 images
- Define an enumeration type triangleType that has the values scalene, isosceles, equilateral, and noTriangle.b. Write a function triangleShape that takes as parameters three numbers, each of which represents the length of a side of the triangle. The function should return the shape of the triangle. (Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third side.)c. Write a program that prompts the user to input the length of the sides of a triangle and outputs the shape of the triangle.3. Write a code for craps game. Craps is a dice game in which the players make wagers on the outcome of the roll, or a series of rolls, of a pair of dice.The rules of the dice game craps are as follows:You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots, respectively. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, you win and play is over. If the sum is 2, 3 or 12 on the first throw you lose and play is over. If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, that sum becomes your “point.” To win, you must continue rolling the dice until you “make your point” (i.e., roll that same point value). You lose by rolling a 7 before making your point. 4. Write a program which prompts the user for their age. If they are 19 or younger inform them that qualify for student discounts. If they are between 20 and 65 inform them that they qualify for no age…10 - In an examination, 500 students appeared. Out of these students, 38 % got A+ grade, 45 % got B+ and the remaining just passed. Assuming that no student failed, find the number of students who got A+, B+ and the number of students who just passed.(Python code)
- c++ (A) write the definition of the Circle class. (B) Write a test program implementing the relational operators (<, <=, ==, ! =, >, >=) to compare the radius of two circle. See the sample outcome Figure 1. in the test program, your code will perform the followings; (A) Creates two circles with the radius 5 and 6 respectively. (B) Use the operator < and display the area of the circle that has the smaller radius. (C) Use the operator == and display the area of the bigger circle if the two circles are not the same. You need to use one of the operators to determine which radius is bigger.Define an enumeration type triangleType that has the values scalene, isosceles, equilateral, and noTriangle. Write a function triangleShape that takes as parameters three numbers, each of which represents the length of a side of the triangle. The function should return the shape of the triangle. (Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third side.) Write a program that prompts the user to input the length of the sides of a triangle and outputs the shape of the triangleWrite a code for craps game. Craps is a dice game in which the players make wagerson the outcome of the roll, or a series of rolls, of a pair of dice.The rules of the dice game craps are as follows:You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots,respectively. After the dice have come to rest, the sum of the spots on the two upward faces iscalculated. If the sum is 7 or 11 on the first throw, you win and play is over. If the sum is 2, 3or 12 on the first throw you lose and play is over. If the sum is 4, 5, 6, 8, 9 or 10 on the firstthrow, that sum becomes your “point.” To win, you must continue rolling the dice until you“make your point” (i.e., roll that same point value). You lose by rolling a 7 before making yourpoint(in python)
- Write a code for craps game. Craps is a dice game in which the players make wagerson the outcome of the roll, or a series of rolls, of a pair of dice.The rules of the dice game craps are as follows:You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots,respectively. After the dice have come to rest, the sum of the spots on the two upward faces iscalculated. If the sum is 7 or 11 on the first throw, you win and play is over. If the sum is 2, 3or 12 on the first throw you lose and play is over. If the sum is 4, 5, 6, 8, 9 or 10 on the firstthrow, that sum becomes your “point.” To win, you must continue rolling the dice until you“make your point” (i.e., roll that same point value). You lose by rolling a 7 before making yourpoint.17. Redo Programming Exercise 16 so that the user can also input the cost of producing one liter of milk and the profit on each carton of milk.1. Assume x is an int which has been declared and assigned a valid value. x guaranteed to change after this code snippet. if (x<5) x--; if (x>=5) cout << x + 1; a) True b) False 2. Assume x is an int which has been declared and assigned a valid value. x guaranteed to change after this code snippet. if (x<5) x--; if (x>=5) x++; a) True b) False
- 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.gien two variables a and b of type int, that have been decalred and gien values, compute their sum then assign it to another int variable,c, that has also already been declared. c++int p =5 , q =6; void foo ( int b , int c ) { b = 2 * c ; p = p + c ; c = 1 + p ; q = q * 2; print ( b + c ); } main () { foo (p , q ); print p , q ; } Explain and print the output of the above code when the parameters to the foo function are passed by value. Explain and print the output of the above code when the parameters to the foo function are passed by reference. Explain and print the output of the above code when the parameters to the foo function are passed by value result. Explain and print the output of the above code when the parameters to the foo function are passed by name.