Complete this program that reads an integer n and prints the following diamond pattern with 2 *n - 1 asterisks at its widest point. This is the pattern when n is 3:
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: 3. Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer.…
A: The Answer is in given below steps
Q: Find the numbers that can be expressed as the product of two nonnegative integers in succession and…
A: Answer:-
Q: You will select one of the problems below and create a program that uses nested selections to solve…
A: Given:- You will select one of the problems below and create a program that uses nested selections…
Q: What is the value of the expression m+m/n+m+m%n? Assume that, int m=18, n=4;
A: Here m=18; n=4; m + m/n +m + m%n m =18, n =4 18 + 18/4 + 18 + 18%4 = 18 + 4 + 18 + 2 =…
Q: Do it quick I don't have my system right now so i need your help Program to find the sum of…
A: NOTE: As the programming language is not mentioned in the question. So, we have solved this question…
Q: Suppose you are given the following information: Integer:first_day. This is the day on Jan 1…
A: #include <bits/stdc++.h>using namespace std; int main(int argc,char *argv[]) { int…
Q: Show manual tracing for the following program and find the final output. In the program,…
A: The program given is: #include<stdio.h>int a, b;int func1(float x);void func2(int x, float y);…
Q: Write a program that reads three edges for a triangle and computes the perimeter if the input is…
A: The following is the program
Q: There are N students in a class. Each student got arr[i] (1 <=i<= N) marks in mathematics exam. Geek…
A: Answer of the given question Here is the python code of the given problem: OUTPUT:
Q: Using Java Let |p|2 denote the size of p in bits. Your task is to generate a safe prime q, where…
A: ANSWER: Here is the program to print Sophie Germain's number beneath n. The answer for this is…
Q: 2. In this problem, you will write different programs to x n , where x ∈ R, n ∈ N. a)…
A: #include <iostream>#include<iomanip>using namespace std; int main() { double x; // x is…
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: As seen in this Pascal's Triangle: 1 1 1 1 1 1 3 3 1 1 4 6. 4 1 Each row begins and ends with 1.…
A: Program is given below: import java.io.*; class PascleTriangle { public int factorial(int i) {…
Q: What is the output of the following code segments (when nun independently)? int [] myAry =…
A:
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: OUTPUT char arr [3] [3] = { {'A', 'H', 'B'}, {'T', 'K', 'N'}, {'D', 'I', 'G' } }; for (int k=1;…
A: According to the information given:- we have to explain how the code is traverse and give the…
Q: Make a tunction that calculates the CUBE-ROOT of the input number and returns the value (single or…
A: It is defined as a computer programming language. It was developed by Denis Ritchie in 1970. Each C…
Q: Instructions: Print out the cube values of the numbers ranging from 1 to 1000 (inclusive). However,…
A: """Write a program that prints cube of numbers from 1 to 10 whichare not divisible by 3 or 5""" #Run…
Q: int RFunc(int a, int b) { if (a <= 0 || b <= 0) { return a+b; } else { return RFunc (a-1, b-1) +…
A: HERE IS STEP BY COMPLETE SOLUTION REGARDING YOUR PROBLEM
Q: Q3. a) Write a program to find the resultant (R) of two forces F1 & F2 with angle 0 between them as:…
A: #include<bits/stdc++.h> using namespace std; int main(){ int f1,f2; cin>>f1>>f2;…
Q: D. The results become the results of one digit. For example, if a result is a two-digit number, add…
A: import java.util.Scanner;//Import Statementpublic class Main{ public static void main…
Q: The person gives an unknown amount of positive integers. The program should give the second lowest…
A: Logic: Accept number from the user until enter a negative number. Initially consider number as…
Q: The following code examines two variables -- x and y -- and prints the largest odd number among…
A: We are given a function largestOdd that finds the largest odd number among two numbers x and y…
Q: (THIS IS THE GIVEN CODE) int main(int argc, char *argv[]) { int first_day = atoi(argv[1]);…
A: I have implemented the given requirements as mentioned above in C++. Proper validations are in…
Q: or faster sorting of letters, the United States Postal Service encourages companies that send large…
A: Encoding number system:- Interchange (ASCII) The most widely used coding scheme is still ASCII.…
Q: 1- Write a java program that asks the user to input two integers intStart and intEnd then computes…
A: 1) read start and end value 2)Iterate n from 10 to 100 with step size 10 3)in above loop, For…
Q: Write a funtion transform (word, num_day) that takes as an argument a word and the number of the day…
A: In this question, we are asked to write function in python which return the transformed word as per…
Q: , pi); you can use a Monte Carlo method to estimate the value of the real constant ππ. Buffon's…
A: Code: import java.util.*; class Main{ public static void precisionCompute(int x, int y, int n)…
Q: We want to represent positive integer n as a sum of addends, where each addends is an integer number…
A: Actually, given information is: We want to represent positive integer n as a sum of addends, where…
Q: Alice, a friend of Mr. Bernard’s, wants to compose a song. She asks Mr. Bernard for help. Although…
A: For input {1, 2, 3, 4, 5, 6, 7}, FSM will be
Q: Trace the following code and write what it does. void Finals(X, Y, m, n) int i1, ju1, k1; while (i…
A: We are given the following code and we need to trace what it does. void Finals(X, Y, m, n){ int…
Q: The following code will print int n=2, m=3, *p; p=&m; p=&n; n=*p; printf("%d\n", n);
A: Here in the code, the concept of the pointer is used for printing the value of p. The Pointer in C…
Q: A square-free integer is an integer which is not divisible by the square of another integer larger…
A: Write a program which given an nonzero integer n,checks whether or not n is square free.In addition…
Q: Q3. a) Write a program to find the resultant (R) of two forces F1 & F2 with angle 0 between them as:…
A:
Q: You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form…
A: import string alpha = string.ascii_lowercase n = int(input()) L = [] for i in range(n): s =…
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: You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form…
A: Given information: - Please find the solution in the below step
Q: Given a zero-terminated sequence of non-zero integers in order from smallest to largest, output the…
A: Explanation: #first create a list in python. List = [-10 ,-4,-2,1,5,6,8,9,0] #Then create a variable…
Q: Write an algorithm that asks the user to enter a positive integer n and prints the sum of the…
A: Required: Write an algorithm that asks the user to enter a positive integer n and prints the sum of…
Q: The Collatz conjecture says that you will always eventually reach the number 1. This conjecture has…
A: python program: # taking input from the user N = eval(input("N:")) # if the input is non-positive…
Q: Modify the program to also print the powers of 2 for 2^20 and 2^30. And label 2^10, 2^20, 2^30 as K,…
A: Code : #include <stdio.h> #include <math.h> //Main function int main() { int i=0,…
Q: You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form…
A: import string alpha = string.ascii_lowercase n = int(input()) L = [] for i in range(n): s =…
Q: Modif
A: NOTE: Programming language is not mentioned, so doing in C++ In this question, we are asked to print…
Q: Write a program that calculates the value of (pi) from the following series. Stop calculation when…
A: Logic: Initially assign pi with 0 and i with 1. Iterate a loop until value of pi exceeds 8.7235.…
Q: You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Trace the following code and write what it does. void Finals(X, Y, m, n) { int i=1, j=1, k=1; while…
A: void Finals( int X[], int Y[], int m, int n){ int i=1, j=1,k=1; //checking the value of i and…
Q: diagram last two digits of your student number (For example, if your student number is 1910602041,…
A: Here value of n is 34 So T = 34%25 = 1 i=2 j=0 i<9 -> True j=2 j<10 -> True T= T+j+i =…
Q: Write a program that prompts the user to enter the length from the center of a pentagon to a vertex…
A: Program Structure: • Declare double type variables to store side and area of pentagon. • Read…
how to solve this problem, really need help, please.
Complete this program that reads an integer n and prints the following diamond pattern with 2 * n - 1 asterisks at its widest point. This is the pattern when n is 3:
--*--
-***-
*****
-***-
--*--
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- CFG: Example 1 • Draw the CFG for the following code: int f(int n){ } int m = n* n; if (n < 0) else return 0; return m;(Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.double tab1[5] = {2,3,4,5,6}; double tab2[5] = {6,5,4,3,2}; for(int i = 0;i<5;i++) { tab1[i] = tab1[i]*tab2[i]; cout<<tab1[i]<<" "; } 12 15 16 15 16 15 15 16 15 12 12 15 16 15 12 12 15 12 15 12
- Code uses C++ language If the user chooses to generate a Pentagono This is a combination of a triangular shape and a square shape -- a symmetrictriangle sits on top of a rectangle.o The triangular shape must be symmetric about the vertical axis. There must beexactly one character in the first line, and the number of characters increases by2 in every successive lineo The rectangle shape must have LENGTH lines of height and all lines are 13characters wide.o Make sure to add delay to view a progressively growing pentagon, otherwise youwill just see the final shape. Code for triangle: for (int i = 1; i <= length; i++) { sleep (1); for (int j = length - i; j > 0; j--) cout << " "; for (int b = 1; b <= i; b++) cout << char(rdm) << " "; cout << endl; } Code for square: for (int row = 1; row <=…The program segment has errors. Find as many as you can. // This code should average a set of numbers. int numCount, total;double average; cout << "How many numbers do you want to average? "; cin >> numCount;for (int count = 0; count < numCount; count++) {int num;cout << "Enter a number: "; cin >> num;total += num; count++;}average = total / numCount;cout << "The average is << average << end1;#include <stdio.h>int main(){int d;int s[20],i, r, p, lg=0,m;char c;printf("Enter number of salesman(max 20): ");scanf("%d", &d);for(i=0; i<d; i++){ printf("\n salesman %d sales: ");scanf("%d", &s[i]);}for(i=0; i<d; i++){for(r=i+1; j<d; r++){if(s[i] > s[r]){p= s[i];s[i] = s[r];s[j] = p;}}}printf("\nsalesman lowest to highest: ");for(i=0; i<d; i++){printf("%d\t", s[i]);}for(i=0;i<m;i++){printf("\n highest sales: %d ",lg);if(lg<=s[i])lg=s[i];break;}getch();} >>> the upper part output should be like this enter number of salesman (max 20): 5 salesman 1 500 salesman 2 300 salesman 3 1000 salesman 4 200 salesman 5 1000 in the lower part the lowest to highest the output should become like this salesman 4 200 salesman 2 300 salesman 1 500 salesman 3 1000 salesman 5 1000 highest total sales : 2000
- main.cpp 1 @include 2 using namespace std; int maxResult() 4-( int maxVal = 0; 6. for (int i = 0; i <= n; i += a) { for (int j = e; j <= n i;j += b) !! 10 (float)(n - (i + j)) / (float)(c); 11 float z = 12 if (floor (z) { int x = i / a; int y 13 ceil(z)) 14 15 16 j/ b; max (maxVal, x + y + (int)z); 17 maxVal = 18 19 20 21 22 return maxVal; 23 } 24 int main() 26 { 25 27 28 cout << maxResult( ); 29 30 return 0; 31 } Input Compilation failed due to following erors) main.cpp:7:23: error: 'n was not declared in this scope 7 for (int i = 0; i <= n; i t a) main.cpp:7:31: error: 'a' was not declared in this scope 7 for (int i 0; i <= n; i t a) main.cpp:9:36: error: 'b' was not declared in this scope for (int j = 0; j <- n i; j b) %3D main.cpp:11:45: error: was not declared in this scopeCompute: z = x/|y| #include <stdio.h>#include <math.h> int main(void) { double x; double y; double z; scanf("%lf", &x); scanf("%lf", &y); /* Your code goes here */ printf("%.2lf\n", z); return 0;Arranging Pebbles Write a program that can arrange a group of pebbles into its designated position. We have 4 types of pebbles: Red, white, blue, and green colored pebbles. Supposed that we have an n-number of pebbles, the program should be able to check the color of the pebble and arrange them in such a way that it will look something like this: Example, if there are 9 pebbles; 1 green, 3 white, 2 blue, and 3 red, the program will output something like this: RRRWWWBBG
- Arranging Pebbles Write a program that can arrange a group of pebbles into its designated position. We have 4 types of pebbles: Red, white, blue, and green colored pebbles. Supposed that we have an n-number of pebbles, the program should be able to check the color of the pebble and arrange them in such a way that it will look something like this: Example, if there are 9 pebbles; 1 green, 3 white, 2 blue, and 3 red, the program will output something like this: RRRWWWBBG NOTE: The program will let the user to enter the pebbles and then the program will automatically arrange it. Sample output 1: R=Red, W-White, B=Blue, G=Green Enter pebbles: rwgbrgwbrg Arranged pebbles: RRRWWBBGGG Sample output 2: R=Red, W-White, B=Blue, G=Green Enter pebbles: abcde Invalid input Notice that the arrangement of the pebbles is: Red, White, Blue, GreenComplete the code: string cars[5] = {"Volvo", "BMW", "Ford", "Mazda", "Honda"}; for(int i = 0; i < - ; i++) { cout << cars[i]< "\n"; } %3Da) Write a program that asks user to enter number of vertices in an undirected graph and then the adjacency matrix representing the undirected graph. The program, then, must display whether the given graph is connected or not. You will find two sample runs of the program below. Sample 1 Sample 2 Enter number of vertices: 3 Enter number of vertices: 3 Enter adjacency matrix: 0 1 1 1 0 0 1 0 0 Enter adjacency matrix: 0 1 0 1 0 0 0 0 0 The graph is connected. The graph is not connected.