Question 4: Write an algorithm that asks the user to enter an integer number then prints the sum of even digits and the sum of odd digits within the number. Example: if the user enters: 2169 The algorithm should print: The sum of even digits is 8 and sum of odd digits is 10.
Q: Homework: Write a program that calculates y = -x².
A: here is Your Code #include <stdio.h> int main(){ int x=2,y; y=-x*x; printf("y =…
Q: The following returns ______ when passed the argument 3. int example(int n) { if (n == 0)…
A: The question is to write the output of the code if the argument passed is 3.
Q: The following pseudo-code describes a menu-driven algorithm: loop ask the user to input one of the…
A: The solution of the above program is
Q: Madison County collects property taxes on the assessed value of property, which is 60 percent of its…
A: Madison County collects property taxes on the assessed value of property, which is 60 percent of its…
Q: The program segment has errors. Find as many as you can. int num1 = 0, num2 = 10, result; num1++;…
A: Lets see the solution.
Q: A positive whole number n > 2 is prime if no number between 2 and n (inclusive) evenly divides n…
A: Python program: from math import sqrt def prime(n): divisor = 2 found = False…
Q: 2: commas.cpp) Write a program that accepts a 7-9 digit integer and echoes the number with commas…
A: Answer in step2
Q: Q2: using java please type this code Code Problem 2 Book Sales Barnes and Nobles sells a package…
A:
Q: Write a program that asks user to enter a number until user enters -1. Then the program should…
A: Since you have not mentioned programming language I'm doing this in c++.
Q: A positive whole number n>2 is prime if no number between 2 and sqrt(n)(inclusive) evenly divides n.…
A: Python program: #taking a input for nn = int(input('enter the value of n:')) is_prime = True…
Q: Create a program that asks the user for any number. Then rounds off the number into its nearest…
A: The code implementation in C++ is given below. The Algorithm: The user is prompted to enter a…
Q: n a program, write the program's algorithm that calculates the sum of odd integers (T1) from 1 to N,…
A: I have provided code in step2
Q: Homework 1. Write a program to have the user guess a number stored in the program. If he guesses…
A: According to the question below the complete program: Programming language is not mention so i am…
Q: Q2: Write a program that inputs a five-digit integer, separates the integer into its individual…
A: Code
Q: 1. Write a program that asks the user to enter n and then it computes the value of the sum: 12 +…
A: Program to prompt the user to enter an integer n and to print the sum of series up to n.…
Q: In a program, write the program's algorithm that calculates the sum of odd integers (T1) from 1 to…
A: n=int(input()) t1=0 t2=0 t3=0 for i in range(1,n+1,2): t1+=i for i in range(2,n+1,2): t2+=i…
Q: 1. Write a an algorithm that asks the user to input a positive integer n and counts how many of the…
A: The algorithm is a step-by-step program instruction in a human-readable format. The number of steps…
Q: age, write a
A: #include<stdio.h> int main (void){ int array[] = {1,6,15,9}; int length = sizeof array /…
Q: A prime number is called an Additive prime if the sum of its dig- its is also a prime number. Write…
A: Loops in C++: A loops repeatedly executes statements until a given condition is true. Before…
Q: 1. Write a program that asks the user to enter n and then it computes the value of the sum: 12 +…
A: Since the language is not mentioned I have done this using Python 3.
Q: rite an algorithm and flowcharts for the following: a) Sum the even numbers for n numbers b) Display…
A: For a: Define variable n and take user input for the limit in it. Define variable i and initialize…
Q: def foo(num): if (num<=0): return else: print(num/2,end=" ") foo(int(num/2)) print(num/2,end=" ")
A: To do: Output of the given code
Q: what is the algorithm? Write a program that prompts the user to enter a number with the range of…
A: An algorithm is a set of instructions designed to perform a specific task. ALGORITHM: step1: take…
Q: Find the numbers that can be expressed as the product of two nonnegative integers in succession and…
A: Note :- You have not mention the language of program ,So i am doing your question in C++ language.…
Q: Write a program that asks the user to type 10 integers. The program must compute how many even and…
A: Program Explanation: Declare the header files Define the main function Declare an array to store 10…
Q: (Rounding) Write a program that prints the value 100.453627 rounded to the nearest digit,tenth,…
A: Since the programming language is not mentioned, I have coded this using C language.
Q: 5. Write a program that generates random numbers as below, random number between 0 and 10 Numl Num2…
A: In the below program srand(time(0)); has been used to make sure that each number generated is…
Q: (Compute 7) You can approximate 7 by using the following series: 1 1 1 1 6 x (1 + TT = + + .. . 4 9.…
A: Given:
Q: generate a random number between 10 and 99 using Math.random). It should then ask the user to ente…
A: import java.util.Scanner;public class MyClass { public static void main(String args[]) {…
Q: Exercise 1: In this exercise we are asked to write a program that prompts the user for a positive…
A: Input n if(n>0) { while(n>0) { r=n%10; //find remainder…
Q: Q1: Write an algorithm that receives a number, n, as its input which calculates the following…
A: Algorithm: It is a set of instructions for solving a problem.
Q: (Separating Digits in an Integer) Write a program that inputs one five-digit number, sep- arates the…
A: answer is in the 2nd step
Q: A prime number is called a Mersenne prime if it can be writtenin the form 2 p - 1 for some positive…
A: Since the programming language is not mentioned, assuming the programming language to be C language.
Q: Write a program that consists of the following algorithm: num1 =4, num2= 4* 5-11, sale = 0.02 *…
A: Write a program that consists of the following algorithm: num1 =4, num2= 4* 5-11, sale = 0.02 *…
Q: Write a program that asks user to enter a number. Then the program should print the sum of all…
A: Given: Write a program that asks user to enter a number. Then the program should print the sum of…
Q: Write a program that prompts the user to enter two integers.
A: Since the programming language is not mentioned in the question, we will answer this question in C++…
Q: Magic program ask user to enter three integers by the user, the three integers represent left bound,…
A: for(i=l; i<r+1; i++){ bool flag = true; int rem= i%10, temp = i; int…
Q: Write an algorithm that asks the user to enter an integer number then prints the sum of even digits…
A: Aim: To create a program that print addition of all the odd digits of a number and even digits of…
Q: Q2: Write a program that inputs a five-digit integer, separates the integer into its individual…
A: Below is the implementation of above problem in C++:
Q: Q: Write a program that reads non-negative integer number and determines whether it is odd or even…
A: Q1) The semicolons should be commas The correct answer is Option d Answer: In for loop the 3…
Q: 12. Ask for a number then get the sum from 1 until the entered no. Enter a number: 3 e.g. Answer is…
A: Editable C code:- #include <stdio.h>int main() { int n, i, sum = 0; printf("Enter a…
Q: Complete a program for counting digits and displaying their total count at the end of the program }
A: Complete code: #include <iostream>using namespace std;int main(){int n;int digits = 0;cin…
Q: Write Psuedo-code of an algorithm that will repeatedly ask the user to enter a number 10 times. If…
A: Psuedo code is step by step written outline that can be easily translated into the program.
Q: (Game: learn addition) Write a program that generates two integers under 100 and prompts the user to…
A: Write a program using python language which will find a sum of two random numbers under 100 and then…
Q: In a program, write the program's algorithm that calculates the sum of odd integers (T1) from 1 to…
A: Algorithm Create two threads T1, T2 & T3 using the below syntax, where T1, T2 & T3 are used…
Q: 5. A positive whole number n > 2 is prime if no number between 2 and Vn (inclusive) evenly divides…
A: A prime number can be denoted as a number that is divisible by 1 and itself. The answer is given in…
Q: In this program you will ask the user for three integers and then print out the minimum value.…
A: Ask the user for three integers and then print out the minimum value.
Q: The program segment has errors. Find as many as you can. // This code should display the sum of two…
A: There are two mistake in the code semi-Colum is missed after the while condition then condition in…
Step by step
Solved in 2 steps with 1 images
- 1. Write a an algorithm that asks the user to input a positive integer n and counts how many of the squares of the integers from 1 to n end in a 1.2. Write a an algorithm that asks the user to input a positive integer n and counts how many of the squares of the integers from 1 to n end in a 4 and how many end in a 9.Fibonacci sequence: The first two numbers of the fibonacci sequence are 1 and 1, and sequential numbers are the sum of the previous two. Write a program that prompts the user for an integer n and then prints the first n numbers of the Fibonacci sequence (Please type answer no write by hend)The company « Super discounted used cars inc.» pays their employees according to this chart: 250$ per months plus 50$ per car sold. If the salesman sells more than 10 cars, the employee receives a bonus of 5% of the total of his sales, in addition to his regular salary. Each month, the owner sits in front of the computer, and enters the following information: The name of the employee, the number of cars sold, as well as the total of all the sales for the month. Write an algorithm that will calculate the salary of an employee for the month, and then display on the screen, his name, total cars sold, base salary, bonus if applicable and entire salary.
- "QUICK-BASIC64 Write an algorithm that finds and prints the sum of the first N terms of the series 1,4,7,10,... for a given integer N>0. (Please explain everything the program in details and please check whether the program runs or not by using q-basic64. Thank you so much)"InstructionsLet n be a nonnegative integer. The factorial of n, written n!, is defined by 0! = 1, n! = 1·2·3· · ·n if n ≥ 1. For example, 4! = 1·2·3·4 = 24. Write a program that prompts the user to enter a nonnegative integer and outputs the factorial of the number.In a program, write the program's algorithm that calculates the sum of odd integers (T1) from 1 to N, the sum of even integers (T2), the sum of integers increasing by 5 (T3) and prints these values (T1, T2, T3) on the display.
- Prime factors of an integer \( n \) are a set of prime numbers that can be multiplied together to obtain \( n \). Write a proHide Transcribed Text Prime factors of an integernare a set of prime numbers that can be multiplied together to obtainn. Write a program that asks the user to enter a number and displays the prime factors ordered from smallest to largest. If the number entered by the user is less than 2 then there are no prime factors and the message "No prime factors" should be displayed. The following algorithm can be used to discover the prime factors: - initialize factor to 2 - while factor is less than or equal tondo: ifnis evenly divisible by factor then - conclude that factor is a factor ofn- dividenby factor using floor division else: - increase factor by 1 Adapt the algorithm so it can be used to print out the prime factors of a number. Notes: - You can assume that the number entered by the user will be an integer number. - The output must be in the format shown in the…In a program, write the program's algorithm that calculates the sum of odd integers (T1) from 1 to N, the sum of even integers(T2), and the sum of integers increasing by 5 (T3) and prints these values (T1, T2, T3) on the screen.Java program please. Ask user to enter number between 1-5 Generate random number between 1-5 if random number is same as users number then print congrats you won lottery
- units = int(input(" Please enter Number of Units you Consumed : ")) if(units < 50): amount = units * 2.60 surcharge = 25 elif(units <= 100): amount = 130 + ((units - 50) * 3.25) surcharge = 35 elif(units <= 200): amount = 130 + 162.50 + ((units - 100) * 5.26) surcharge = 45 else: amount = 130 + 162.50 + 526 + ((units - 200) * 8.45) surcharge = 75 total = amount + surcharge print("\nElectricity Bill = %.2f" %total) Find the error and resolve the problem.Exercise 2:Write a Java program that asks the user for three integer values and displays them sorted indescending order (use if-condition). If all numbers are the same then print it once only.• Update your code so it displays the numbers in ascending order.• Update your code to accept 3 float numbers instead of integers, will it work?Assume that start and end are integers.Return the average all of the numbers from start to end inclusive.For example,average(3, 5) returns 4.0, since (3 + 5) / 2 = 4