Question

In: Computer Science

write code with proper comments for ever step the code should be in form of pseudocode                            &

write code with proper comments for ever step the code should be in form of pseudocode                                   

To Print Triangle of any size, by taking size as input.
To Print Triangle of any size, by taking size as input. If size is 4 then triangle is:
To calculate Factorial of any number.
To calculate the power of any given number.
To Print Table of Any Number up till 10: as shown in this figure.
for a program which reads 10 integers from the user, and output the largest value
from input numbers.

Solutions

Expert Solution

Triangle:

        for (int i = 1; i <= n; i++) {

  

            // loop to print the number of spaces before the star

            for (int j = rows; j >= i; j--) {

cout<<" ";

            }

              // loop to print the number of stars in each row

            for (int j = 1; j <= i; j++) {

cout<<"*";

            }

//new line

        }

Factorial:

int factorial(int n)

{

    if (n == 0)

    return 1;

    return n * factorial(n - 1);

}

Power:

int power(int a, int b)

{

    if (b == 0)

        return 1;

    else if (b % 2 == 0)

        return power(a, b / 2) * power(a, b / 2);

    else

        return a* power(a, b / 2) * power(a, b / 2);

}

Table:

    int n = 5; // Take any input number

    for (int i = 1; i <= 10; ++i)

        cout << n << " * " << i << " = "  << n * i << endl;

Largest:

int a[10];

int i;

int greatest;

printf("Enter ten values:");

//Store 10 numbers in an array

for (i = 0; i < 10; i++)

{ scanf("%d", &a[i]); }

//Assume that a[0] is greatest

greatest = a[0];

for (i = 0; i < 10; i++) {

if (a[i] > greatest)

{ greatest = a[i]; }

}

At the end greatest will have the largest number


Related Solutions

Write an algorithm (in pseudocode, with proper indentation for blocks of code in loops or conditional...
Write an algorithm (in pseudocode, with proper indentation for blocks of code in loops or conditional statements) that finds and returns the location of the first negative integer in a sequence of integers.
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:               ...
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:                    Input a number and store it in X; if X > 1 then    Y := X + X;    X := 0; endif; Y := Y + 1; Output the value of Y; N.B: You should include the MARIE code in your Answer, with an explanation of each instruction in your code beside it. Example:              Subt One         /Subtract 1 from AC Add a...
Python Program : simplist form and include comments Shopping Data by Zip Code Have you ever...
Python Program : simplist form and include comments Shopping Data by Zip Code Have you ever noticed that some stores ask you for your zip code before “ringing up” your transaction? Suppose you have been given three (3) text files (named kroger.txt, publix.txt, and ingles.txt) from popular grocery stores, containing zip codes of customers at each store. Additionally, you have been given a file named zipDirectory.txt which contains the zip code and city name (each on its own line). This...
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
write the code in MATLAB with comments and show the inputs and results of the code...
write the code in MATLAB with comments and show the inputs and results of the code for the question below. Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an...
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an earthquake is in the range [0, 3), “medium” if M is in the range [3, 6), “large” if M is in the range [6, 9) and “epic” if M is greater than or equal to 9, where M is input by a user via the keyboard. (in c++)
1. Write code in mips that will play battleships. Include comments in code on what each...
1. Write code in mips that will play battleships. Include comments in code on what each part is doing.
write JAVA code with the following condition Write the pseudocode for a new data type MyStack...
write JAVA code with the following condition Write the pseudocode for a new data type MyStack that implements a stack using the fact that you have access to a queue data structure with operations enqueue(), dequeue(), isEmpty(). Remember that every stack should have the operations push() and pop(). Hint: use two queues, one of which is the main one and one is temporary. Please note that you won’t be able to implement both push() and pop() in constant time. One...
write the pseudocode and code to solve the following: you are given a list. determine the...
write the pseudocode and code to solve the following: you are given a list. determine the sum of all the elements in the list without using the built in puthon function sum(). Take your code and create your own function and name it my_sum_algo() which will return the sum of numbers PS please write comments in the code for my understanding, and please write jn jn PYTHON 3 languge. Thank you, have a great day !
Write a pseudocode for the following code: /*every item has a name and a cost */...
Write a pseudocode for the following code: /*every item has a name and a cost */ public class Item {    private String name;    private double cost;    public Item(String name, double cost) {        this.name = name;        this.cost = cost;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public double getCost() {        return cost;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT