1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mamont248 [21]
2 years ago
14

(20 points). Some matrixes have very special patterns, for example, in the following matrix, the numbers in the first row are eq

ual to the number of their respective column; the numbers in the first column are equal to the square of the number of their respective row; when the row number equals to the column number, the elements are equal to 1; the rest elements are the sum of the element just above them and the one to their left. Write a user-defined function program in the program, you need to use while loops), and then use the function you write to create the following matrix (show the command you use). 1 4 9 16 2 1 10 26 3 4 1 27 4 5 8 13 9 22 1 23
Computers and Technology
1 answer:
Nostrana [21]2 years ago
3 0

Answer:

#include <iostream>

using namespace std;

void matrix(){

   int row = 5, col = 6;

   int myarr[row][col];

   for (int i = 0; i < 5; i++){

       for (int x = 0; x < 6; x++){

           if (i == 0){

               myarr[i][x] = (x+1)*(x+1);

          }else if ( x == 0){

               myarr[i][x] = (i+1)*(i+1)*(i+1);

           } else if ( i == x){

                myarr[i][x] = (i+1);

           } else{

                myarr[i][x] = myarr[i-1][x] + myarr[i][x-1];

           }

        }

   }

   for (int i = 0; i < 5; i++){

       for (int x = 0; x < 6; x++){

           cout<< myarr[i][x] << " ";

       }

       cout<< "\n";

}

}

int main(){

   matrix();

}

Explanation:

The C++ source code defines a two-dimensional array that has a fixed row and column length. The array is a local variable of the function "matrix" and the void function is called in the main program to output the items of the array.

You might be interested in
Assume that an int variable age has been declared and already given a value. Assume further that the user has just been presente
Musya8 [376]

Using the knowledge of computational language in C++ it is possible to write a code that assume that an int variable age has been declared and already given a value

<h3>Writting the code:</h3>

<em>#include<stdio.h></em>

<em>#include<conio.h></em>

<em>int main()</em>

<em>{</em>

<em>//variables to rad choice and age</em>

<em>char choice;</em>

<em>int age;</em>

<em>//read age and choice</em>

<em>printf("\tEnter your age: ");</em>

<em>scanf("%d", &age);</em>

<em>//fflush the keyboard buffer before reading choice</em>

<em>fflush(stdin);</em>

<em>printf("\tEnter your choice: ");</em>

<em>scanf("%c", &choice);</em>

<em>//print the invalid message if the choice is otherthan the S,T,B</em>

<em>if(choice!='S' && choice !='T' && choice !='B')</em>

<em>{</em>

<em>printf("Invalid menu choice");</em>

<em>getch();</em>

<em>}</em>

<em>else if (age <22)</em>

<em>{</em>

<em>if (choice =='S')</em>

<em>{</em>

<em>printf("\tvegetable juice");</em>

<em>}</em>

<em>else if (choice =='T')</em>

<em>{</em>

<em>printf("\tcranberry juice");</em>

<em>}</em>

<em>else if (choice == 'B')</em>

<em>{</em>

<em>printf("\tsoda");</em>

<em>}</em>

<em>}</em>

<em>else</em>

<em>{</em>

<em>if (choice == 'S')</em>

<em>{</em>

<em>printf("\tcabernet");</em>

<em>}</em>

<em>else if (choice =='T')</em>

<em>{</em>

<em>printf("\tchardonnay");</em>

<em>}</em>

<em>else if (choice == 'B')</em>

<em>{</em>

<em>printf("\tIPA");</em>

<em>}</em>

<em>}</em>

<em>//pause the console output until user press any key on keyboard</em>

<em>getch();</em>

<em>}</em>

See more about C++ at brainly.com/question/19705654

#SPJ1

8 0
10 months ago
Write the function mystrchr(). the function has two parameters: a const char * s pointing to the first character in a c-style st
GrogVix [38]
<span>c. return a pointer to the first appearance of c appearing inside s and nullptr (0) if c does not appear inside s.</span>
7 0
3 years ago
After saving her presentation initially, Leah realizes she needs to add another content slide. She adds the slide and is ready t
liberstina [14]

Answer:

a, c, & e

Explanation:

7 0
3 years ago
_______ is a form of crime that targets a computer system to acquire information stored on that computer system, to control the
julia-pushkina [17]

Answer:

Option (A) is the correct answer.

Explanation:

A Computer system can be the target for the crime on which a criminal can acquire the information from the computer system which is stored on it. A Criminal is targeting the system with the help of some software that is entered on the computer system through a network.

In the above question, paragraphs are describing the content related to the crime which targets the computer system. This is a concept of a "computer as target". Hence option "A" is the correct answer while the other is not valid because--

  • Option b suggests the concept behind the storage device of a computer but in the question, it is about the crime of a computer.
  • Option c suggests the concept behind the computer is a criminal but in the question, it is about the crime of a computer.
  • Option d suggests the concept behind the communication of a computer but in the question, it is about the crime of a computer.
4 0
3 years ago
Explain what happens if you try to open a file for reading that does not exist.
ZanzabumX [31]

Answer:

Exception is thrown and the file is created with 0 length.

Explanation:

While opening a file there is an error occur which shows the file does not exist that means an  exception is thrown.

And this error can be occur when the size of the file is very very low means the file is a size of 0 length. So to avoid this error we have to exceed its length from the zero length.

8 0
3 years ago
Other questions:
  • What is another name for “low-angle lighting”? Side lighting Top lighting Under-lighting Three-point lighting
    15·2 answers
  • Brittany just pulled up a database table with employee information that contains 50 records of employees at her company. Which o
    12·1 answer
  • What is the term used for the document that describes the scenes and sequence of a game?
    6·1 answer
  • You are splitting up all your apples equally between 3 people. which statement below will calculate how many apples will be left
    12·1 answer
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
  • Which interpersonal skill is the most important for a telecom technician to develop?
    7·1 answer
  • Who is big brain me or you
    14·1 answer
  • Make variables to represent the length and width of a rectangle, called length and width, respectively. You should set length to
    7·1 answer
  • 1.a computer can create an output based on the input of the user.
    13·1 answer
  • identify the difficulties with the k-nearest neighbor algorithm. a. both a and b b. calculate the distance of the test case from
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!