Answer:
Explanation:
The following code is written in Python. It creates a program that keeps printing out a menu allowing the user to create shapes. These shapes are saved in an array called shapes. Once the user decides to exit, it prints all of the shapes in the array along with their total area. The output can be seen in the attached picture below. Due to technical difficulties, I have added the code as a txt file below.
Answer:
Explanation:
The following code is written in Java and it uses nested for loops to create the array elements and then the same for loops in order to print out the elements in a pyramid-like format as shown in the question. The output of the code can be seen in the attached image below.
class Brainly {
public static void main(String[] args) {
int jagged[][] = new int[5][];
int element = 1;
for(int i=0; i<5; i++){
jagged[i] = new int[i+1]; // creating number of columns based on current value
for(int x = 0; x < jagged[i].length; x++) {
jagged[i][x] = element;
element += 1;
}
}
System.out.println("Jagged Array elements are: ");
for ( int[] x : jagged) {
for (int y : x) {
System.out.print(y + " ");
}
System.out.println(' ');
}
}
}
Answer:
The program to this question can be described as follows:
Program:
#include <iostream> //defining header file
using namespace std;
int main() //defining main method
{
int x; //defining integer variable
for(x=0;x<=100;x++) //defining loop to count value from 0 to 100
{
if(x%7==0) //check value is divisable by 7
{
cout<<x<<endl; //print value
}
}
return 0;
}
Output:
please find the attachment.
Explanation:
In the above code, an integer variable x is declared, which is used in the for loop, in this loop variable "x" starts from 0 and ends when the value of x is less than and equal to 100.
- Inside the loop an, if block is used that defines a condition that is (i%7==0), it will check, that the value is divided by 7.
- In this loop, a print method is used, that prints its values.