Listing 6.7, PrimeNumberFunction.py, provides the isPrime(number) function for testing whether a number is prime. Use this function to find the number of prime numbers less than 10,000.
Q: Which line has an error, or all lines are correct int *p; p = (int *) malloc( sizeof(int) );…
A: Which line has an error, or all lines are correct int *p; p = (int *) malloc( sizeof(int) );…
Q: 4.main(){ int i,j; long int f=1; for (i=1, i< 10; i++) f=f*i; } prinf(“%ld",f);}
A: Factorial Program in C: Factorial of n is the product of all positive descending integers. Factorial…
Q: 1- int a = 1, b = 0; %3D if (a -1) {a = b = 23 ;} cout << x << " "<y< endl; 2- int x; for (x = 1;…
A: I think the x and y in the first program may be a and b. If so, here is the output and the correct…
Q: What does the following code snippet print? for (int i = 8; i < 17; i++) { if (i % 5 != ®) { print(i…
A:
Q: What will happen in the following C code snippet? int a = 100, b = 200; int *p = &a, *q = &b; %3D…
A: The given code snippet is given by: int a=100,b=200;int *p=&a,*q=&b; p=q; The code snippet…
Q: Q7: Write a program that reads a collection of car speeds as long as the speeds do not exceed 100…
A: Program Approach: Including necessary header files Using namespace for standard input output…
Q: int comp_count (int x[], int N, int v)
A: According to the question we need to translate the given C code to Assembly Code: int comp_count…
Q: def f(x): print (x) X = 3.0 5.0 f(x) print (x) X%3D O 5, then 3 O 3, then 5 O 3, then 3 O 5, then 5
A: Given python code is def f(x) : print (x) x = 3.0x = 5.0f(x) print (x)
Q: int al] =(2, 6, 3, 8, 12, 10, 14); What is the sum of a[1] and a[5]? O a. 16 O b. 20 O c. 14 O d. 18
A: The solution is provided below.
Q: what sequence of numbers would be printed if the following function were executed with the value of…
A: The given code segment is: def xxx (N): print (N) if (N < 5): xxx (N + 2)…
Q: QUESTION 10 def cube (number): for i in range (number, number): for j in range (number) : print…
A: In place of FILL THIS PART just write number*number*number Hence the answer to be filled in the box…
Q: positive integer named N, Get the remainder of N/10 and put it to a Get the integer part of the…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: What will be the value of a, b, c after the execution of the followings int a=5, b=7, c=111; c =++a…
A: The values of a, b, and c after the execution of given statements are: a: 6 b: 6 c: 2
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: - What will be the value of M as a result of the following operations? int M; M=33/5; cout<<M; 06,5…
A: We will run this code in a proper C++ program. Then we will get the output.
Q: Q2/ Write a program that prints the block letter “B" in grid of stars like this: ****** * * ****** *…
A: First, middle, last lines have all *'s whereas in other lines, line starts and ends with *
Q: lQuestion:: There are blank 3 digit counting numbers that are made using only the odd digits…
A: Here in this question we have asked that how many 3 digit number are possible with odd digit…
Q: void copy (int& a, int& b, int& c) { a *= 2; b*= 2; c*= 2; int main () { int x = 2, y = 5, z = 7;…
A: Given: We have the c program given in which we have to find out the return values.
Q: A number in base 2 (binary) is a number such that each of its digits is 0 or 1. To convert from…
A: As no programming language is mentioned, it is solved using basic C++
Q: please code in python You are probably familiar with the famous Fibonacci sequence of numbers,…
A: The question is to write the recursive python code for the given problem.
Q: int a[ 10] = {1,5,3,8,4,2,6,9,7}; int *p; p = &a[2]; p[0] = 10; p[1] = 15; What are the values of a?
A: Required:
Q: int [] X = {12,15,12}; int [] Y = {1,2,3}; int i=0; for(int a:X) { if(a%2==1) { Y[i]=a; i++; } %3D
A: In the above question, we have to print the output of the given program. In this there are two…
Q: What is the final value of x when the following code is run? int x; for (x =1; x<20; x+=2) O 20 O 18…
A: the for loop will start from x =1 and will run till x < 20 with an increment of 2. #include…
Q: 5. Given variables int areaBound and int sum, write a snippet of code that assigns to sum the result…
A: Given:
Q: int i, j, k; mid - left + 1; right - mid; int Le[a], Ri[b]; for (i = 0; i < a; i++) Le[i] = x[left +…
A: Merge Sort is a Divide and Conquer algorithm. The mergeSort() function divides the input array into…
Q: i. Void search(int * m[],int x) { } void search(int * m, int x) ii. {
A: Given code is 1) Void search (int * m[],int x) { } 2) void search (int*m,int x) { }
Q: int X[10]={2,0,6,11,4,5,9,11,-2,-1); %3D From the code above, what is the value of X[8] ?
A: Code: #include <iostream>using namespace std; int main(){ //as index value starts from 0…
Q: 2. int a = 0, i = N; while (i > 0) { a += i; i /= 2;
A: As per our guideline we are supposed to answer only first question, please re upload another…
Q: (a) # include int main() { int i 2, j= 3, k, I ; float a, b; k =i/j*j; 1=j/i*i; a = i/j*j; b…
A: I give the output along with explanation for the above code
Q: Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length? 5 3 and 2 4 2…
A: EXPLANATION: In the above statement, the x is the multi-dimensional array. In the multi-dimensional…
Q: def sparechange(quarters, dimes, nickels, pennies): spareAMT = 25 * quarters + 10 * dimes + 5 *…
A: 1) Below is program to display equivalent dollers for the change quarters, dimes, nickels and…
Q: int k = 3; %3D nPrint ("A message", k-2);
A: Given :
Q: int t = 7; int s = 17; if (t > 6) { s t= 5; } else { s -= 2; } D-2 D 5 O 22 D 17
A: 1) the expression should include 98 and 101, but anything lower or higher should sound an alarm.…
Q: QUESTION 18 Int xt 200, int yt 100 Int dt, d2 mov EAX, x1: mov EBX, yt: push EBX pop ECX mov d2, ECX…
A: The register EAX,EBX,ECX are data register ,it is used to store the value . The answer is 18)100…
Q: can you check which part my code wrong? #include using namespace std; int main() { int board…
A: In the given c++ program, the 11th line contains a for loop and 15th line also contains a for loop.…
Q: Q2) Write and test the following power() function that returns x raised to the power n, where n can…
A: C++ Code for Above : #include <bits/stdc++.h> using namespace std; //power function double…
Q: int x=22, y=17; if((x>30 || y<2)) cout<<"BAHRAIN"; else cout<<"MANAMA"; A MANAMA B BAHRAINMANAMA C.…
A: The given code is: int x=22, y=17 here x is not greater than 30 so first condition is false. y…
Q: int a[100], b[1000], c[1000]; // get some data for a, b, and c 0; i < 100; i++) for (j for (i %3D =…
A: The code given contains some errors which are corrected according to the syntax of C++ and the…
Q: Q2/-A- What is printed by the following code fragment? Int x1=4 , y1, x2=6, y2; yl=++x1; y2=x2++;…
A: The code fragment given: int x1 = 4, y1, x2=6, y2; y1 = ++x1; y2 = x2++; x2 = y1++; cout…
Q: 25. What will the following code print out def addtwo(a, b): added - a +b return a x- addtwo (2, 7)…
A: Answer in step 2
Q: lef foo (a : Int) { ... var b = a + 3 ... def bar(g : Int) { val h = b + g ... } def jat(...) {…
A: In the function foo, every time in the while foo is called with the value 3 because Val is passed…
Q: What error will occur when you run the following code?def main():print(min(min(5, 6), (51, 6)))def…
A: UnboundLocalError: local variable 'min' referenced before assignment This error will occur.…
Q: Consider the following lines of code: int a = 5; %3D double b = 10; double c = a / b; C (int)c +1;…
A: After the code have been executed,the value of c is 1.0. Therefore the correct option is None of the…
Q: 5. Implement fl(x2, x₁) = Σ 0,3, and £2(x2, x₁) = 0,1,2, using a 4×2ROM? ✓ CI Familia v
A: It is defined as Read Only Memory, is a memory device or storage medium that stores information…
Q: 3. Write a JavaScript function to calculate the circumference of the circle, note that pi=3.14 and…
A: Actually, JavaScript is a programming language for the web.
Q: I'm running a 5-star restaurant and I can only have the best items on my menu. My menu offers 6…
A: Here we have given code in c++ for the question asked. You can find the code in step 2.
Q: int a=9, b=10; cout<<(a++) +(b--); getch(); return 0;
A: NOTE: There were some issues in your code which have been removed to get the answer. Getch() is used…
Listing 6.7, PrimeNumberFunction.py, provides the isPrime(number) function for testing whether a number is prime. Use this function to find the number of prime numbers less than 10,000.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- 1 int[] a = new int[n]; 2 a[0] = 0; a[1] = 1; 3 int x = 0; 4 for (int i = 2; i < n; i++) { 5 x = 3 * (i-1) * (i-1); 6 x += 3 * i - 2; 7 a[i] = a[i-1] + x; 8 } The code can be simplified by replacing lines 5, 6, 7 with a single line of code. Write the single line of code below:What will be the two lines displayed after executing the following code? def pair(e,f): ka=e-f api() return ka def api(): ka=4 print(ka) print(pair(934,91)) Separate your answers by a decimal point, eg, if the two lines are 17 and 15, then write 17.15Complete and modify the code. 1 def to_share(total_candies, n_friends=4): 2 """Return the number of leftover candies that must be 3 smashed after distributing 4 the given number of candies evenly between 3 friends. 5 6 >>> to_share(91) 7 1 8 """ 9 return total_candies 10 11 to_share(10, 4) 12 to_share(5) 13 to_share(1, 5)
- Q4. Write a JavaScript that asks the user to enter 3 integers and find the largest integerCreate a Javascript function that takes a numeral (just digits without separators (e.g. 19093 instead of 19,093) and returns the standard way of reading a number, complete with punctuationWrite code that prints a random number of lines between 2 and 10 lines inclusive, where each line contains a random number of 'x' characters between 5 and 20 inclusive. For example: xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxx xxxxxx xxxxxxxxxxx xxxxxxxxxxxxxxxx
- A number in base 2 (binary) is a number such that each of its digits is 0 or 1. To convert frombinary to decimal (base 10), the digits starting from the right are multiplied by powers of 2(starting at 0) and added. For example, the value in decimal of 10011 is calculated as follows: 1 ×20+ 1 ×21+ 0 ×22+ 0 ×23+ 1 ×24=19 Write a program that reads from the user a 5-digit integer representing a value in binary anddisplays its equivalent value in decimal. Note that if the user enters an integer which digits areother than 0 or 1, the program displays a message stating that the number is not valid.in python “c” represents a crop and “w” represents a water source. Each water source hydrates the eight tiles around it (including itself) Input the number of rows and columns in the crop field:ROWS> 4COLUMNS> 4Input each row of the crop field.ROW0> c c c wROW1> w c c cROW2> c c c cROW3> c w c cNot all crops are watered!OUTPUT FalseThe following crops are not watered:OUTPUT [(2, 3), (3, 3)] Input the number of rows and columns in the crop field:ROWS> 7COLUMNS> 1Input each row of the crop field.ROW0> cROW1> wROW2> cROW3> cROW4> wROW5> cROW6> wAll crops are watered!OUTPUT TrueQ12,. A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome..
- C++ A robot is initially located at position (0; 0) in a grid [?5; 5] [?5; 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print "Back to the origin!" to the console and stop the program. If it reaches the boundary of the grid, print \Hit the boundary!" to the console and stop the program. A successful run of your code may look like:Down (0,-1)Down (0,-2)Up (0,-1)Left (-1,-1)Left (-2,-1)Up (-2,0)Left (-3,0)Left (-4,0)Left (-5,0)Hit the boundary! or Left (-1,0)Down (-1,-1)Right (0,-1)Up (0,0)Back to the origin! About: This program is to give you practice using the control ow, the random number generator, and output formatting. You may use <iomanip> to format your output. You may NOT use #include "stdafx.h".I'm running a 5-star restaurant and I can only have the best items on my menu. My menu offers 6 items, each represented by a number from 1-6. If an item on my menu does not sell or does not sell that much compared to others, I must act and replace it with something that sells! Identify which dishes do not sell. If every dish sells, print the set of dishes that were ordered least. Input: A single line containing the dish number that were ordered. Treat as one number. INPUT: 156356231 Output: The list of dishes not ordered in numerical order. If every dish sells, print the set of dishes that were ordered least. Separate each number with a new line. OUTPUT: 4Q 3.I] Write a Java program to read the length and breadth using console and find the area of the rectangle. If the area is greater than 5oo then find the Perimeter of the rectangle. Area of rectangle=length∗breadth Perimeter of the rectangle=2∗(length breadth)