What is output by the following code segment ? (Supposed all variables are declared as int) count = 1; while (count <= 5) { innerCount = 1; while (innerCount <= (12 - count / 2)) { cout <« " ". innerCount++; } innerCount = 1; while (innerCount <= count) { cout <« "0"; innerCount++; } cout << endl; count++; }
Q: Suppose that the input is 0 0 8 12 50 7 13 –1. What is the output of the following code? (2, 3)…
A: Given program: #include <iostream> using namespace std; int main() { int num, sum, count;…
Q: What is the output of the following program segment? int count = 0;while (++count < 5)cout…
A: Given Program: //include the header file #include <iostream> using namespace std;…
Q: What does the code below do if I answer "s"? Comment on the code to show what the different parts…
A: Given that What does the code below do if I answer "s"? Comment on the code to show what the…
Q: The value of X after execut į = 0 x = 0
A: Ans.) Option B i.e. X=30 Explanation:- When i=0, x=0, (i)mod5=0=> x=0+0=0 and i=1+0=1 => X=0…
Q: Consider the following code: Random rand = new Random(); int a = rand.nextInt(100); int b =…
A: The Random class is a java API class. The class is defined in java.util package. The class Random is…
Q: Assume j=5, what is the new value of j at the end of the following loop? for (int i = 8;i >= 0; i =…
A: First option "non of all" is the correct option. Explanation provided in the next step. Algorithm:…
Q: What is the output of the following?int count = 3;while (--count > 0)cout << count <<…
A: 2 1
Q: Write the result of the following code: No need to attach your full code or an image of the output,…
A: As per our guidelines we are supposed to answer only 3 sub parts of a question but each sub part of…
Q: What is the value returned by the call mystery(3)? int mystery(int n) { if (n == 0) return -l; else…
A: Answer: G. 5
Q: What is the output of the following code segment? (NOTE: There are no spaces between output) void…
A: Programming Approach: Defining the appropriate header file. Defining method test that holds the…
Q: What is the output ofthe following code? count = 0; put << count << " "; ile (count < 5);
A: the output for the above program is.....
Q: Discount = ticket price * discount rate / 100 final price ticket price- Discount Number of…
A: Your java program is given below as you required with an output.
Q: What is the last value of K after executing the following code? int K; for (K=0;K<22;K=K+5) cout<…
A: answer is 20 explanation: initially k=0 for next iteration k=5 then for next iteration k=10…
Q: ne output from the following segment of screen, int f 1(); void f_2(int = 3); float f_3(int &); zint…
A: Ans -- The code's output after the compilation gives ::
Q: void Secret (char txti[], char txt2[]) ( if(stramp (txt1, txt2)) strepy (txt2, "golf"); else strepy…
A: I provide the output screenshot for each condition.
Q: What is the output of the following program segment? int count = 5;while (--count > 0)cout…
A: Explanation of the program segment: An int variable is declared and initialized to 5. A while…
Q: Run code below and fix it. mylist =…
A: The problem is about correction of the python code.
Q: What is the output of the following code segment? Assume user input is: soccer football void…
A: Task :- identify the output for given C++ code.
Q: fix code below make it run correctly import random mylist =…
A: Answer in step2
Q: What's wrong in the following statement, provided k is a variable of type int? for(k = 2, k <= 12,…
A: According to the question for loop is that function loop sequence order for make the series in the…
Q: he following code isn't working correctly and I am unable to figure out why. The for loop is never…
A: srandom((unsigned)time(NULL) + my_rank);value = random() % 10;if (my_rank % divisor ==…
Q: What is the output of the following program segment? int count = 0;while (count++ <= 5)cout…
A: Given program: //include the header file #include <iostream> using namespace std;…
Q: There are THREE errors in the code below. % Clear variables from workspace clear b - [2 5 7 10]; C -…
A: In this question, we have given the MATLAB code. The elements are accessed like the matrix but b and…
Q: What is the output of the following program (when embedded in a complete program)? int count = 6;…
A: 5 4 3 2 1
Q: Run this code and check if it works if not how would you fix it! n=int(input("Number of rounds of…
A: The given code has some loose ends. It's working but not effectively according to the game. The…
Q: What is the output of the following program segment? int count = 1;docout << count * (count -…
A: To run your given program segment, let us frame the entire code as below : If we analyze the…
Q: What is the output of the following code? int *intArrayPtr;int *temp;intArrayPtr = new…
A: NOTE: - *intArrayPtr = *(intArrayPtr - 1) 1 2 * i; Syntactically above line is wrong written in…
Q: What is output by the following code segment? char string1[] = "How are you?"; for ( int i = 0; i…
A: Program Explanation: Define the header file Define the main function Declare and define a character…
Q: What is the output of the code snippet below: int[] intArray = new int[10]; for(int x = 0;…
A: 1. public class Main{ public static void main(String[] args) { //intArray variable is not…
Q: Given int result, int count and the following code snippet 1. count = 1; 2. printf ("At first: count…
A: 1) Above code snippet does various operations with count and result variable. Below are the points…
Q: Write a program that takes five students' quizzes in a course. Consider each student has given ten…
A: Best student will score highest average (sum of all quizes divided by the number of quizes) Worst…
Q: What will be the value of x[8] after the following code is executed? final int NUM = 10;int[] x =…
A: In the given code, NUM is a final variable. When a final keyword is placed in front of a variable,…
Q: What is wrong in the following program? void p(int i){ cout << i << end1; } int…
A: Explanation: In the code given, both function signatures have identical function name p(int).…
Q: What is the output of the following code? Extra Credit: What are the values of heightCounter,…
A: given code: #include <stdio.h> int main(){ int…
Q: Write a "Wizard Duel Matching" program in Python. In this program, two wizard names wll be taken as…
A: import mathdef getNames(): name1 = input("Enter first name: ") name2 = input("Enter second…
Q: int result= %3D%3B For (int i-o;ikait) int count = 7; Whire count >=0) resuit ttj Count--
A: According to the Question below the Solution:
Q: Prompt the user for successive input lines, with the prompt "Enter course number, units, and grade,…
A: Here below is the code in Python is :
Q: Consider the following code segment. What is the value of i and sum2 after the for loop…
A: Here, "for" loop executes 4 times because condition is less than 5. Initially, "sum2" is zero and…
Q: What is output by the following code segment ? (Supposed all variables are declared as int) int…
A: The given code is as following- int count =1; while(count <=3) { int innerCount =1;…
Q: Assignment4C Heads or Tails? It is said that a perfectly fair coin will return heads 50% of the…
A: A program that prompt the user for a number of flip coins :-
Q: What is the value of average after the following code? int x, sum = 0,…
A: Here we have declared three variables. Next, we have a loop that generates numbers from 0 to 5,…
Q: Complete the following method by declaring variables s and digit. Make variable s local to the…
A: public String reverseNumber(int n) { String s =""; while (n > 0) {…
Q: 2. Review the defined methods below and write a simplified mathematical expression to represent…
A: The mathematical expression for the function Huh is val = (val -1) until val < 0. So the output…
Q: Which is the correct output of the following code? int s-0; int q-0; int count=0; while(count<=20) {…
A: count variable basically runs from 0 to 20 whenever we encounter a multiple of 5, we would assign…
Q: When the following program is executed, it terminates with an error. Which option best describes the…
A: Wrong options are : a. The function will terminate the program due to invalid syntax. b. The…
Q: Which regular loop corresponds to this enhanced for loop? char[]vowels={'a','e','i','o','u'}; for…
A: Answer is Option c. for(int i=0;i<vowels.length;++i){System.out.println(vowels[i]);}…
Q: I need to display each grade in a seperate line** smith= { "name": "John", "homework": [90.0\n,…
A: The code for the following problem is given below:
Q: The code I am using will not return the correct type. For example the expected answer is [1] and my…
A: I correct the code ,give the correct code ,correct output screenshot ,code screenshot and I also…
Q: Rearrange the following lines of code to simulate the picking of a random playing card. Assume that…
A: The code of rearrangement is as below , firstly selecting rank and then suit ,this because these are…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…
- What value will be returned by the function if a = 8, b=12? %3D int func(int a, int b){ if(a>b){ return a+b; } else if(abe recor #include #include minutes #include limit on int func(int, int, int, int); main(){ srand(time(NULL)); int a, b, c, fNum; printf("Choose three different numbers between 0-39:"); scanf ("%d%d%d", &a, &b, &c); fNum = func (a, b, c, 25); printf("\nThe result: %d", fNum); } int func (int ul, int u2, int u3, int iter){ srand (time (NULL)); int n1=0, i=0, count=0; for (;iz = int('10') what is the value of z?int sum = 0; for (int i 0; i < 5; i++){ sum += i; } cout << sum;Void Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() { Int x = 10; Do1 (x,x); Cout << x << endl; } The output of this program isNumber guessing Game Write a C program that implements the “guess my number” game. The computer chooses a random number using the following random generator function srand(time(NULL)); int r = rand() % 100 + 1; that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if the entered number is larger or smaller than its number. The user then keeps guessing till he/she finds the number. If the user doesn’t find the number after 10 guesses, a proper game over message will be shown and the actual guess is revealed. If the user makes a correct guess in its allowed 10 guesses, then a proper message will be shown and the number of guesses the user made to get the correct answer is also printed. After each correct guess or game over, the user decides to play again or quit and based on the user choice, the computer will make…Look at the following code. int x = 7; int *ptr = &x;What will be displayed if you send the expression *iptr to cout? What happens if you send the expression ptr to cout?C++: Describe how the following call by reference works. Make a comment for each line. void pxc(int& c, int& d) { int k = c; c = d; d = k; } int main() { int a = 15, b = 100; pxc(a, b); }SEE MORE QUESTIONSRecommended textbooks for youDatabase 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:PEARSONC 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 EducationDatabase 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:PEARSONC 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