The GCD (Greatest Common Divisor) of two numbers is the largest positive integer number that divides both the numbers without leaving any remainder. Write a program that prompts the user to enter two positive integers and computes their GCD. For example. GCD of 30 and 45 is 15. Sample Run 1: Enter two integers: 30 45 GCD of 30 and 45 is 15 Sample Run 2: Enter two integers: 55 121 GCD of 55 and 121 is 11
Q: Do it quick The program takes a range and creates a list of tuples within that range with the…
A: NOTE: As the programming language is not mentioned in the question. So, we have solved this question…
Q: Write a program that reads a sentence and store it in an array of characters. The program also reads…
A: #include<bits/stdc++.h>using namespace std;int main(){ char s[1000]; cout<<"Enter…
Q: Write a program that will ask how many number of integers to input (n) and it will read in integer's…
A: Step 1: Accept size of array from user Step 2: Accept array elements from user Step 3: Check for…
Q: (This is a version of Programming Project 2.1 from Chapter 2.) The Babylonianalgorithm to compute…
A: Given: (This is a version of Programming Project 2.1 from Chapter 2.) The Babylonianalgorithm to…
Q: The list of numbers above should be initialized in a single-dimensional array. A simple binary…
A: single-Dimensional Array In the C++ language, a one-dimensional array is the most basic kind of…
Q: Given the following pseudocode: function fun2(n) { var outer_count = 0; var inner_count = 0; for…
A: - We need to talk about the outer_count and the inner_count.
Q: Write a program that takes integer number from user, and then find the total number of digits in it.…
A: Hello Student. A warm greeting from my side. I will try my best to answer your question in as…
Q: Write a program that prints 20 random numbers between 10 and 99 inclusive. Read in one integer from…
A: Note: As per our guidelines, we are supposed to answer one question. Please repost other question.…
Q: Write a program that reads two integers (M and N) from user until user provide 0 for M and N. The…
A: Code: n = int(input("Enter the value of n : ")) m =…
Q: Write a program that displays a Pascal triangle. The program prompts the user to enter the number of…
A: Given: please use java to answer the following question
Q: 5. Write a program that reads 3 items, item1, item2, item3, from the keyboard a. if 1 and 2 are the…
A: I give the code as per your requirement along with output and code screenshot in python
Q: Java: Write a program that prompts for a sequence of integer inputs and displays cumulative totals.…
A: Here, first you need to declare integer array. Then you can prompt user to enter how many elements…
Q: A group of monkeys have N bananas in day 1. In the next each day, these monkeys eat half the number…
A: For this, first lets take an examplewith d= day which is givenn = no of banana left on day d Let d =…
Q: Write a program that takes a sequence of integer numbers and N as an input from the user and prints…
A: Solution:-- 1)The question given in the portal has expected for the solution to be in the language…
Q: Write a program that uses random function to randomly generate 6 integers between 0 and 99 with 0…
A: Required: Write a program that uses random function to randomly generate 6 integers between 0 and 99…
Q: Write a program that asks the user to enter his/her name and then reads integers, finds the largest…
A: Provided the Java Program with the requirements as given in the question. Added the appropriate…
Q: Q1:A, B, C are three positive numbers (A<=B<=C). Given a list of seven numbers which are made of A,…
A: Answer
Q: Write an algorithm that reads 10 integer numbers and calculates the average for numbers that are…
A:
Q: Write a program that ask the user to enter two integers N and M then prints the summation of even…
A: You have not specified any programming language in the question. So, I have used C++ language to…
Q: When analyzing data sets, such as data for human heights or for human weights, a common step is to…
A: Below is the required C program: - Approach: - Define the header file. Define the main function.…
Q: Write a code to calculate double func(int x,int y) recursively. When x <1 & ys 1 When x and y both…
A: Input : Value of x Value of y Output : Value returned by func(x,y).
Q: shows how to write a program to factor a polynomial of the form x² + bx + c, where b and c are…
A: #include <iostream>#include <cmath>using namespace std;int main() {float a, b, c, x1,…
Q: Write a program that inputs one five-digit number, separates the number into its individual digits…
A: //C++ program #include <iostream> using namespace std; int main(){ int n,a[5],i=4;…
Q: Write a program that reads a sentence and store it in an array of characters. The program also reads…
A: Summary: In this question, we have to write a python program in which we have to ask the user to…
Q: 1. Write an algorithm that asks the user to enter ten numbers and then prints the largest one
A: NOTE: ACCORDING TO COMPANY POLICY WE CAN SOLVE ONLY 1 QUESTION. YOU CAN RESUBMIT THE QIESTION AGAIN…
Q: Write a program that reads an integer between 1972 and 2001 (year of birth). Print the age group…
A: #include<iostream>using namespace std;int main(){ int x; cout<<"Enter the year of birth…
Q: The function 'CountWords' is given below to find the number of words in a sentence. Which of the…
A: ANS: - The correct option is D. if((P[i]==' '&&P[i+1]!=' ')||P[i] =='\0') It checks if the…
Q: Write a program that displays all possible combinations for picking two numbers from integers 1 to…
A: Code: #include <iostream> using namespace std; int main() { int count=0;//declaring and…
Q: (Tabular Output) Write a Java application that uses looping to print the following table of [Output]…
A: We need to use nested for loops to solve this problem.
Q: Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume…
A: import java.util.*;import java.util.stream.IntStream;public class Main {public static void…
Q: Given the following pseudocode: function fun(n) { var outer_count=0; var inner_count=0; var sum = 0;…
A: Source Code of "Javascript Program" function fun(n){ var outer_count = 0; var inner_count = 0;…
Q: Write a program that prompts the user to enter an integer (n) and a sum value (s). The program…
A: PROGRAM CODE: import java.util.*; // import java utility packagepublic class…
Q: Write a program that uses do...while loops to perform the following steps: Prompt the user to input…
A: Let us consider a C++ program that uses do.. while loops to perform the following steps: Prompt the…
Q: A positive integer is called a perfect number if it is equal to thesum of all of its positive…
A: Program approach: We are using java language to create the code of the given problem. code of the…
Q: Write a NumPy program to count the number of days of a given month for the given years import numpy…
A: Here I have used a function named datetime64(). This function datetime64(), is present in the NumPy.…
Q: Write a function that will calculate the sum of all the numbers multiple of 3 from N down to 1 using…
A: C Program: #include <stdio.h> int computeTotal(int n){ // Declare variable sum and…
Q: A sequence of n>0 integers is called a jolly jumper if the absolute values of the differences…
A: Answer: Here not mention any specific language use so we have done code in C++ programming language…
Q: Modify this program so that it writes the values in two columns, like this: 32.00 54.00 67.50 29.00…
A: In Output, you can specify each field width as 8 and finally total can be displayed with width 10
Q: Write a program that takes two integer numbers from user N and x, then calculate the following sum:…
A: Here is Your Code n = int(input("Please Enter a Number N "))x = int(input("Please Enter a Number x…
Q: Write a program that lets the user enter a charge account number. The program should determine if…
A: Given:
Q: An emirp ( prime spelled backward) is a nonpalindromic prime numberwhose reversal is also a prime.…
A: Java Code: public class Main{ public static void main(String[] args) { int cnt = 0;…
Q: Write an algorithm for a program that determines all composite numbers between 1 and 20
A: In order to find all the composites between 1 and 20, the following steps are performed : Using…
Q: Write a program that will compute and display the sum of the factorials of the numbers from 1 to n,…
A: Start Enter number Calculate factorial of number from 1 to n display stop
Q: Write a program that performs arithmetic division. The program will use two integers, a and b…
A: The C++ program to compute division of two variables a and b. Take input a and b from user…
Q: Write a Java program that prompts the user to enter two positive integers and find their greatest…
A: Given: Greatest common Divisor
Q: The function 'CountWords' is given below to find the number of words in a sentence. Which of the…
A: The complete function definition of CountWords is as follows: int CountWords(char *P){ int count…
Q: Write a program that reads three integers a, b, and n, and prints a count of the numbers between a…
A: write a program that reads threee integers a,b and n and prints a count of the number between a and…
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
- In python Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest). Zero is considered a non-negative integer. Ex: Enter a list of numbers: 10 -7 4 39 -6 12 2 The non-negative and sorted numbers are: 2 4 10 12 39In PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The output of this code should be a third sequence that is a COMBINATION of both sequences 1 and 2 and is sorted in non-decreasing order where if there are two of the same number they are put together in the final sequence. Such as 1, 20.3, 20.3, 66, 7, 4 please do this using PYTHON, ONLY using while loops. NO language of "break", "len", "True", or "return" anywhere in the code! DO THIS USING 3 SEPARATE LISTS!(This is a version of Programming Project 2.1 from Chapter 2.) The Babylonianalgorithm to compute the square root of a positive number n is as follows:1. Make a guess at the answer (you can pick n/2 as your initial guess).2. Compute r = n / guess.3. Set guess = (guess +r) / 2.4. Go back to step 2 until the last two guess values are within 1% of each other. Write a program that inputs a double for n, iterates through the Babylonian algo-rithm until the guess is within 1% of the previous guess and outputs the answer as a double to two decimal places. Your answer should be accurate even for largevalues of n.
- Given a square matrix with the elements 0 or 1, write a program tofind a maximum square submatrix whose elements are all 1s. Your programshouldprompt the user to enter the number of rows in the matrix. The program then displaysthe location of the first element in the maximum square submatrix and thenumber of rows in the submatrix. Here is a sample run: Enter the number of rows in the matrix: 5 ↵EnterEnter the matrix row by row:1 0 1 0 1 ↵Enter1 1 1 0 1 ↵Enter1 0 1 1 1 ↵Enter1 0 1 1 1 ↵Enter1 0 1 1 1 ↵EnterThe maximum square submatrix is at (2, 2) with size 3 Your program should implement and use the following method to find the maximumsquare submatrix:public static int[] findLargestBlock(int[][] m)The return value is an array that consists of three values. The first two values arethe row and column indices for the first element in the submatrix, and the thirdvalue is the number of the rows in the submatrix.Write a program to place ten queens on 10 x 10 chessboard in such a way that one queen is to bein each row. A program will use 2 DIMENIONAL array x[r][c] to do this configuration. If x[r] hasvalue c, then in row r there is a queen in column c. Write a program that asks a user to enter thecolumns that contain queens in the ten rows. The program then places the queens in thesecolumns (one per row) and prints the board.Write a program that reads an integer between0 and 1000 and multiplies all the digits in the integer. For example, if an integeris 932, the multiplication of all its digits is 54.Hint: Use the % operator to extract digits, and use the / operator to remove theextracted digit. For instance, 932 % 10 = 2 and 932 / 10 = 93.Here is a sample run: Enter a number between 0 and 1000: 999The multiplication of all digits in 999 is 729
- Make a C-Language code of the problem: Modify the code such that the program will be able to generate a list of the first N perfect square numbers and give out its sum. Perfect squares are the squares of whole numbers: 1, 4, 9, 16, 25, 36, ... etc. See the sample output in the picture #include <stdio.h> bool isPerfectSquare(int x){ //insert code for isPerfectSquare() function here } int getSum(int *arr, int size){ //insert code for getSum() function here } void printArray(int *arr, int size){ //insert code for printArray() function here } int main(){ //insert code for main() function here return 0;} Note: Do not change the initial function definitions. You are free to use more functions and variables as you see fit.In python, The function decodeFromAscii takes a list L of integers in the range 32 through 126. Each item in L is an ASCII code representing a single printable character. The function accumulates the string of characters represented by the list of ASCII codes and returns that string. For example, decodeFromAscii([78, 105, 99, 101, 33]) returns "Nice!" because N is chr(78), i is chr(105), c is chr(99), etc. Note: ASCII was created in the 1960's so programmers could have a standard encoding for common keyboard characters as numbers. It was later expanded to create Unicode so that characters from languages other than English, mathematical symbols, and many other symbols could also be represented by numerical codes. For example: Test Result print(decodeFromAscii([36, 49, 44, 48, 48, 48])) $1,000 print(decodeFromAscii([115, 110, 111, 119])) snowWrite a program that reads in three integers and prints “in order” if they are sorted in ascending or descending order, or “not in order” otherwise. For example, 1 2 5 in order 1 5 2 not in order 5 2 1 in order 1 2 2 in order
- " Given positive integers n and r, list all the r-permutations, withrepetition allowed, of the set {1, 2, 3, . . . , n} " Develop a mini calculator that could allow a user to enter the input r and n and the calculator would shows the output. Your calculator must based on questions above Example if user input n = 3 and r = 2. the answer will display the list 1,1 1,2 1,3 2,1 2,2 2,3 3,1 3,2A palindromic number is a positive integer that reads the same forward as backward. For example, the numbers 1, 11, and 121 are palindromic. Moreover, 1 and 11 are very special palindromic numbers: their squares are also palindromic. How many positive integers less than 10,000 have this property, Palindromic? Write a program to list all such numbers together with their squares. The beginning part of your output should look like this: 1 has square 1 2 has square 4 3 has square 9 11 has square 121 22 has square 484.... ...... Hint: If str is a string object, the reverse() function (declared in <algorithm> header will reverse the string. The code to do that is: reverse(str.begin(), str.end());The function sum_evens in python takes a list of integers and returns the sum of all the even integers in the list. For example: Test Result print(sum_evens([1, 5, 2, 5, 3, 5, 4])) 6 print(sum_evens([5, 5, -5, -5])) 0 print(sum_evens([16, 24, 30])) 70