Answer:
RISC is the reduced instruction set and it is used to reduce the total execution time in the instruction set. The addressing modes are lower in the reduced instruction set.
CISC is the complex instruction set computer in which the single instruction can be executed in the low level operation.
1) 2 address:
The 2 address instruction are basically associate with the complex instruction set (CISC).
2) 1 address:
The 1 address instruction is basically associated with CISC ( Complex instruction set) or RISC ( reduced instruction set ).
3) 0 address:
The 0 address instruction is basically associate with either CISC ( Complex instruction set) or RISC ( reduced instruction set ).
(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)
(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)
while (arrowHeadWidth <= arrowBaseWidth) {
// Prompt user for a valid arrow head value
}
Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:
Enter arrow base height:
5
Enter arrow base width:
2
Enter arrow head width:
4
**
**
**
**
**
****
***
**
*
This is what I have:
import java.util.Scanner;
public class DrawHalfArrow
{
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
System.out.println("Enter arrow base height:");
arrowBaseHeight = scnr.nextInt();
System.out.println("Enter arrow base width:");
arrowBaseWidth = scnr.nextInt();
while (arrowHeadWidth >= arrowBaseWidth)
{
System.out.println("Enter arrow head width:");
arrowHeadWidth = scnr.nextInt();
}
// Draw arrow base (height = 3, width = 2)
for(int i=0; i < arrowBaseHeight; ++i)
{
for(int j=0; j < arrowBaseWidth; ++j)
{
System.out.print("*");
}
System.out.println();
}
// Draw arrow head (width = 4)
for(int i=0; i < arrowHeadWidth; ++i)
{
for(int j=0; j < arrowHeadWidth-i; ++j)
{
System.out.print("*");
}
System.out.println();
}
return;
}
}
Answer:
The modified program in Java is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
for(int i = 0; i<arrowBaseHeight; i++){
for(int j = 0; j<arrowBaseWidth;j++){
System.out.print("*"); }
System.out.println(); }
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
System.out.print("*"); }
System.out.println(); }
}
}
Explanation:
This declares the arrow dimensions
int arrowHeadWidth, arrowBaseWidth, arrowBaseHeight;
This get input for the head width
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
This get input for the base width
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt();
This get input for the base height
System.out.print("Base Height: "); arrowBaseHeight = input.nextInt();
This loop is repeated until the head width is greater than the base width
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.print("Head Width: "); arrowHeadWidth = input.nextInt();
System.out.print("Base Width: "); arrowBaseWidth = input.nextInt(); }
This iterates through the base height
for(int i = 0; i<arrowBaseHeight; i++){
This iterates through the base width
for(int j = 0; j<arrowBaseWidth;j++){
This fills the base
System.out.print("*"); }
This prints a new line
System.out.println(); }
These iterate through the arrow head
for(int i = arrowHeadWidth; i>0;i--){
for(int j = 0; j<i;j++){
This fills the arrow head
System.out.print("*"); }
This prints a new line
System.out.println(); }
Answer:
The program to this question as follows:
Program:
#include <iostream> //defining header file
using namespace std;
void PrintPopcornTime(int bagOunces) //defining method PrintPopcornTime that accepts bagOunces
{
//defining conditional statement
if (bagOunces < 3) //if block checks bagOunces less then 3
{
cout << "Too small"<<endl;
}
else if (bagOunces > 10)
{
cout << "Too large"<<endl; //else if value greater than 10
}
else //else block
{
cout << (bagOunces*6) <<" seconds"<<endl; //calculate seconds
}
}
int main()
{
int bagOunces; //defining integer variable bagOunces
cout<<"Enter number: "; //message
cin>>bagOunces; //input value by user
PrintPopcornTime(bagOunces); //calling the method
return 0;
}
Output:
Enter number: 3
18 seconds
Explanation:
In the above C++ language code, the first header file is defined, then the method "PrintPopcornTime" is defined, in this method, an integer variable "bagOunces" is passed as a parameter, inside the method a conditional statement is used that can be described as follows:
In the next step, the main method is defined, inside this method, an integer variable "bagOunces" is defined, which is used for user input and inside this method, the PrintPopcornTime is called.
The completed function "PrintPopcornTime()" can be referred to as given below.
We have,
The completed function "PrintPopcornTime()" as requested:
void PrintPopcornTime(int bagOunces) {
if (bagOunces < 2) {
System.out.println("Too small");
} else if (bagOunces > 10) {
System.out.println("Too large");
} else {
int time = 6 * bagOunces;
System.out.println(time + " seconds");
}
System.out.println();
}
In this function, we check the value of "bagOunces" using conditionalstatements.
If it's less than 2, we print "Too small".
If it's greater than 10, we print "Too large".
Otherwise, we calculate the time by multiplying 6 with "bagOunces" and print it followed by " seconds".
Finally, we print a new line to end the output.
Thus,
The completed function "PrintPopcornTime()" can be referred to as given above.
Learn more about programming of functions here:
#SPJ6
Answer:
Array: (a) All the messages a user has sent.
Variable: (b) The highest score a use has reached on the app. (c) A username and password to unlock the app.
Explanation:
An array generally has more than one value whereas a variable can only contain a single value at any particular point in time. In addition, a variable has a limit whereas an array does not have any maximum limit. Therefore, it can be concluded that option (a) will be stored as an array while options (b) and (c) will be stored as variables.
Answer:
Polynomial Zero() ::= return the polynomial p(x)=0
Boolean isZero(poly) ::= return (poly == 0)
Coefficient Coeff(poly , expon) ::= If (expon tex2html_wrap_inline93 poly) return its corresponding coefficient else return 0
Exponent LeadExp(poly) ::= return the degree of poly
Polynomial Remove(poly , expon) ::= If (expon tex2html_wrap_inline93 poly) remove the corresponding term and return the new poly else return ERROR
Polynomial SingleMult(poly , coef , expon) ::= return poly tex2html_wrap_inline105 coef x tex2html_wrap_inline107
Polynomial Add(poly1 , poly2) ::= return poly1 + poly2
Polynomial Mult(poly1 , poly2) ::= return poly1 tex2html_wrap_inline105 poly2
end Polynomial
Page Design tab
Zoom bar
Answer:
Page pane
Explanation:
This pane is present under the navigation pane, it allow to hop easily from one page to other. Moreover pages can be added using Add Page button.
Page pane makes the view and navigation from on page to another easier and quicker.
Answer: The shell sort is based on insertion sort. Here the list of elements are divided into smaller sub list which are sorted based on insertion sort.
Its best case time complexity is O(n* logn) and worst case is O(n* log^2 n)
Explanation:
Shell sort is an inplace sorting here we begin by dividing the list into sublist and sorting the list with insertion sort. We create interval for dividing the list into sub list until we reach the smallest interval of 1.
The best case is O(n* logn).